Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source 'https://rubygems.org'
gem 'connection_pool'
gem 'csv' # used by the generated mysql2 code (:copyfrom); a bundled gem since Ruby 3.4
gem 'mysql2'
gem 'pg', '1.5.2'
gem 'pg', '1.7.0'
gem 'sqlite3'
gem 'minitest'
gem 'rake'
Expand Down
124 changes: 61 additions & 63 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
GEM
remote: https://rubygems.org/
specs:
abbrev (0.1.2)
activesupport (7.1.3.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
ast (2.4.3)
async (2.46.0)
console (~> 1.29)
fiber-annotation
io-event (~> 1.21)
base64 (0.2.0)
bigdecimal (3.1.5)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
bigdecimal (4.1.3)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
console (1.38.0)
fiber-annotation
fiber-local (~> 1.1)
json
csv (3.2.8)
drb (2.2.0)
ruby2_keywords
ffi (1.16.3)
csv (3.3.7)
drb (2.2.3)
ffi (1.17.4)
ffi (1.17.4-arm64-darwin)
ffi (1.17.4-x86_64-linux-gnu)
fiber-annotation (0.2.0)
fiber-local (1.1.0)
fiber-storage
fiber-storage (1.0.1)
fileutils (1.7.2)
fileutils (1.8.1)
google-protobuf (4.36.2)
bigdecimal
rake (~> 13.3)
Expand All @@ -43,81 +32,90 @@ GEM
google-protobuf (4.36.2-x86_64-linux-gnu)
bigdecimal
rake (~> 13.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
io-event (1.22.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
json (3.1.0)
language_server-protocol (3.17.0.6)
lint_roller (1.1.0)
listen (3.9.0)
listen (3.10.1)
logger
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
mini_portile2 (2.8.7)
minitest (5.24.0)
mutex_m (0.2.0)
mysql2 (0.5.6)
parallel (1.28.0)
parser (3.3.1.0)
logger (1.7.0)
mini_portile2 (2.8.9)
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
mysql2 (0.5.7)
bigdecimal
parallel (2.3.0)
parser (3.3.13.0)
ast (~> 2.4.1)
racc
pg (1.5.2)
racc (1.7.3)
pg (1.7.0)
pg (1.7.0-arm64-darwin)
pg (1.7.0-x86_64-linux)
prism (1.9.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.4.2)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.4.0)
abbrev
rbs (4.2.0)
logger
prism (>= 1.6.0)
tsort
regexp_parser (2.13.1)
rubocop (1.74.0)
json (~> 2.3)
rubocop (1.92.2)
json (>= 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
regexp_parser (>= 2.11.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.40.0)
parser (>= 3.3.1.0)
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
ruby_wasm (2.10.1)
logger
ruby_wasm (2.10.1-arm64-darwin)
logger
ruby_wasm (2.10.1-x86_64-linux)
logger
securerandom (0.3.1)
sqlite3 (2.0.2)
securerandom (0.4.1)
sqlite3 (2.10.2)
mini_portile2 (~> 2.8.0)
sqlite3 (2.0.2-arm64-darwin)
sqlite3 (2.0.2-x86_64-linux-gnu)
steep (1.6.0)
activesupport (>= 5.1)
sqlite3 (2.10.2-arm64-darwin)
sqlite3 (2.10.2-x86_64-linux-gnu)
steep (2.1.0)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
json (>= 2.1.0)
language_server-protocol (>= 3.15, < 4.0)
language_server-protocol (>= 3.17.0.4, < 4.0)
listen (~> 3.0)
logger (>= 1.3.0)
parser (>= 3.1)
parser (>= 3.2)
prism (>= 0.25.0)
rainbow (>= 2.2.2, < 4.0)
rbs (>= 3.1.0)
rbs (~> 4.2)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 4)
strscan (3.0.7)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
terminal-table (>= 2, < 5)
uri (>= 0.12.0)
strscan (3.1.8)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
tsort (0.2.0)
unicode-display_width (3.3.0)
unicode-emoji (~> 4.3)
unicode-emoji (4.3.0)
uri (1.1.2)

PLATFORMS
arm64-darwin-23
Expand All @@ -131,7 +129,7 @@ DEPENDENCIES
google-protobuf (~> 4.0)
minitest
mysql2
pg (= 1.5.2)
pg (= 1.7.0)
rake
rubocop
ruby_wasm (~> 2.7)
Expand Down
4 changes: 2 additions & 2 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ target :gen do
check "examples"
signature "examples"

# stdlib signatures for the types the generated code refers to (BigDecimal, Date, Time, IPAddr, Set, Tempfile; CSV has no useful signature)
library "bigdecimal", "date", "time", "ipaddr", "set", "tempfile"
# stdlib signatures for the types the generated code refers to (BigDecimal, Date, Time, IPAddr, Tempfile; Set is core since RBS 4, CSV has no useful signature)
library "bigdecimal", "date", "time", "ipaddr", "tempfile"
end
2 changes: 1 addition & 1 deletion examples/mysql2/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion examples/pg/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion examples/sqlite3/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module Sqlite3Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?mode: (:deferred | :immediate | :exclusive)?) { (instance) -> T } -> T
def transaction: [T] (?mode: (:deferred | :immediate | :exclusive)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion lib/sqlc_gen_ruby/drivers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class NotFound < StandardError; end
ISOLATION_RBS = 'ISOLATION_LEVELS: Hash[Symbol, String]'

TRANSACTION_RBS = 'def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | ' \
':serializable)?) { (instance) -> T } -> T'
':serializable)?) { (self) -> T } -> T'

private

Expand Down
2 changes: 1 addition & 1 deletion lib/sqlc_gen_ruby/drivers/sqlite3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def class_methods
[
[NOT_FOUND, "class NotFound < StandardError\nend"],
[INITIALIZE, 'def initialize: (untyped db, ?logger: untyped) -> void'],
[TRANSACTION, "def transaction: [T] (?mode: (:deferred | :immediate | :exclusive)?) { (instance) -> T } -> T"]
[TRANSACTION, "def transaction: [T] (?mode: (:deferred | :immediate | :exclusive)?) { (self) -> T } -> T"]
]
end

Expand Down
20 changes: 20 additions & 0 deletions steep_expectations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
severity: WARNING
message: 'Cannot find the declaration of constant: `Mysql2`'
code: Ruby::UnknownConstant
- range:
start:
line: 198
character: 66
end:
line: 198
character: 81
severity: WARNING
message: Empty kwargs doesn't have type annotation
code: Ruby::UnannotatedEmptyCollection
- range:
start:
line: 615
Expand Down Expand Up @@ -53,6 +63,16 @@
severity: WARNING
message: 'Cannot find the declaration of constant: `PG`'
code: Ruby::UnknownConstant
- range:
start:
line: 213
character: 58
end:
line: 213
character: 69
severity: WARNING
message: Empty kwargs doesn't have type annotation
code: Ruby::UnannotatedEmptyCollection
- range:
start:
line: 227
Expand Down
2 changes: 1 addition & 1 deletion test/features_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_command_signatures
assert_includes rbs, 'def copy_authors: (Array[CopyAuthorsArgs] rows) -> void'
assert_includes rbs, 'def list_authors: -> Array[ListAuthorsRow]'
assert_includes rbs, 'def delete_author: (id: Integer) -> void'
assert_includes rbs, 'def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T'
assert_includes rbs, 'def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T'
end

def test_named_nullable_parameters_are_optional_keywords
Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/default/my_queries_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def with_numbers2_go: (c0: Integer) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/default/other_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def no_cols: (c0: Integer, c1: String, c2: Float, c3: String, c4: Integer) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/default/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/ruby31_gemfile/my_queries_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def with_numbers2_go: (c0: Integer) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/ruby31_gemfile/other_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def no_cols: (c0: Integer, c1: String, c2: Float, c3: String, c4: Integer) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/mysql2/ruby31_gemfile/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module Mysql2Codegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion test/golden/pg/default/my_queries_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def with_numbers2_go: (c0: bool) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/pg/default/other_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def no_cols: (c0: bool, c1: Integer, c2: String, c3: Float, c4: String) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/pg/default/query_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def get_author: (id: Integer) -> GetAuthorRow?

Expand Down
2 changes: 1 addition & 1 deletion test/golden/pg/ruby31_gemfile/my_queries_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def with_numbers2_go: (c0: bool) -> void

Expand Down
2 changes: 1 addition & 1 deletion test/golden/pg/ruby31_gemfile/other_sql.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module PgCodegen

def initialize: (untyped db, ?logger: untyped) -> void

def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (instance) -> T } -> T
def transaction: [T] (?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?) { (self) -> T } -> T

def no_cols: (c0: bool, c1: Integer, c2: String, c3: Float, c4: String) -> void

Expand Down
Loading
Loading