skyward-orm 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +66 -48
- data/lib/skyward/orm/adapters/postgresql/connection.rb +64 -4
- data/lib/skyward/orm/adapters/postgresql.rb +95 -76
- data/lib/skyward/orm/adapters/sqlite/connection.rb +87 -0
- data/lib/skyward/orm/adapters/sqlite/constraints.rb +15 -15
- data/lib/skyward/orm/adapters/sqlite.rb +59 -55
- data/lib/skyward/orm/adapters/statement_cache.rb +51 -0
- data/lib/skyward/orm/adapters.rb +12 -6
- data/lib/skyward/orm/cli/boot_file.rb +2 -2
- data/lib/skyward/orm/cli/migration.rb +7 -7
- data/lib/skyward/orm/cli/scaffold/source.rb +49 -30
- data/lib/skyward/orm/cli/scaffold.rb +6 -6
- data/lib/skyward/orm/commands.rb +9 -9
- data/lib/skyward/orm/connection/instrumented.rb +4 -2
- data/lib/skyward/orm/connection/pool.rb +2 -2
- data/lib/skyward/orm/database/decoders.rb +41 -0
- data/lib/skyward/orm/database/schema_check.rb +3 -3
- data/lib/skyward/orm/database.rb +65 -31
- data/lib/skyward/orm/migrations/definitions.rb +13 -13
- data/lib/skyward/orm/migrations/diff.rb +4 -4
- data/lib/skyward/orm/migrations/directory.rb +5 -5
- data/lib/skyward/orm/migrations/runner.rb +8 -8
- data/lib/skyward/orm/migrations/script.rb +9 -9
- data/lib/skyward/orm/migrations/status.rb +7 -7
- data/lib/skyward/orm/migrations/summary.rb +22 -22
- data/lib/skyward/orm/migrations/versions.rb +2 -3
- data/lib/skyward/orm/projection.rb +6 -12
- data/lib/skyward/orm/queries/clauses.rb +201 -112
- data/lib/skyward/orm/query.rb +2 -2
- data/lib/skyward/orm/record.rb +5 -9
- data/lib/skyward/orm/statements/placeholders.rb +3 -3
- data/lib/skyward/orm/statements.rb +34 -28
- data/lib/skyward/orm/tables/column_types.rb +7 -7
- data/lib/skyward/orm/tables/declarations.rb +5 -5
- data/lib/skyward/orm/tables/rows.rb +28 -10
- data/lib/skyward/orm/tables/sources.rb +3 -3
- data/lib/skyward/orm/tables/values.rb +18 -18
- data/lib/skyward/orm/version.rb +1 -1
- data/lib/skyward/orm.rb +15 -14
- data/sig/generated/skyward/orm/adapters/postgresql/connection.rbs +35 -3
- data/sig/generated/skyward/orm/adapters/postgresql.rbs +14 -3
- data/sig/generated/skyward/orm/adapters/sqlite/connection.rbs +55 -0
- data/sig/generated/skyward/orm/adapters/sqlite.rbs +11 -6
- data/sig/generated/skyward/orm/adapters/statement_cache.rbs +37 -0
- data/sig/generated/skyward/orm/adapters.rbs +3 -0
- data/sig/generated/skyward/orm/cli/scaffold/source.rbs +11 -0
- data/sig/generated/skyward/orm/connection/instrumented.rbs +4 -2
- data/sig/generated/skyward/orm/database/decoders.rbs +19 -0
- data/sig/generated/skyward/orm/database.rbs +38 -14
- data/sig/generated/skyward/orm/queries/clauses.rbs +81 -28
- data/sig/generated/skyward/orm/record.rbs +6 -7
- data/sig/generated/skyward/orm/statements.rbs +8 -10
- data/sig/generated/skyward/orm/tables/rows.rbs +1 -1
- data/sig/generated/skyward/orm.rbs +2 -2
- data/sig/manual/pg.rbs +10 -0
- data/sig/manual/skyward/orm/database/decoders.rbs +3 -0
- data/sig/manual/skyward/orm.rbs +9 -3
- data/sig/manual/sqlite3.rbs +13 -2
- metadata +11 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/adapters/statement_cache.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# Only one fiber uses a connection at a time, so its cache takes no lock.
|
|
4
|
+
# @rbs generic S
|
|
5
|
+
class Skyward::ORM::Adapters::StatementCache[S]
|
|
6
|
+
LIMIT: Integer
|
|
7
|
+
|
|
8
|
+
# A statement with more binds isn't kept. Varying IN lists and multi-row
|
|
9
|
+
# inserts are what reach it: each length is different SQL that would churn
|
|
10
|
+
# the cache, PostgreSQL keeps a large plan for each, and parsing is a small
|
|
11
|
+
# part of their cost.
|
|
12
|
+
MAX_BINDS: Integer
|
|
13
|
+
|
|
14
|
+
@limit: Integer
|
|
15
|
+
|
|
16
|
+
@statements: Hash[String, S]
|
|
17
|
+
|
|
18
|
+
# @rbs limit: Integer
|
|
19
|
+
# @rbs return: void
|
|
20
|
+
def initialize: (?Integer limit) -> void
|
|
21
|
+
|
|
22
|
+
# @rbs binds: Array[untyped]
|
|
23
|
+
# @rbs return: bool
|
|
24
|
+
def keeps?: (Array[untyped] binds) -> bool
|
|
25
|
+
|
|
26
|
+
# @rbs sql: String
|
|
27
|
+
# @rbs return: S?
|
|
28
|
+
def fetch: (String sql) -> S?
|
|
29
|
+
|
|
30
|
+
# @rbs sql: String
|
|
31
|
+
# @rbs statement: S
|
|
32
|
+
# @rbs return: S?
|
|
33
|
+
def store: (String sql, S statement) -> S?
|
|
34
|
+
|
|
35
|
+
# @rbs return: Array[S]
|
|
36
|
+
def clear: () -> Array[S]
|
|
37
|
+
end
|
|
@@ -10,6 +10,9 @@ module Skyward::ORM::Adapters
|
|
|
10
10
|
# -> [Skyward::ORM::_Adapter, String]
|
|
11
11
|
def resolve: (String url, schemes: Hash[String, Skyward::ORM::_Adapter], requirer: ^(String) -> void) -> [ Skyward::ORM::_Adapter, String ]
|
|
12
12
|
|
|
13
|
+
# @rbs (Skyward::ORM::_Adapter adapter, Skyward::ORM::Tables::Column column, untyped value) -> untyped
|
|
14
|
+
def decode: (Skyward::ORM::_Adapter adapter, Skyward::ORM::Tables::Column column, untyped value) -> untyped
|
|
15
|
+
|
|
13
16
|
private
|
|
14
17
|
|
|
15
18
|
# The URL can hold a password, so only its scheme is shown.
|
|
@@ -108,6 +108,17 @@ module Skyward::ORM::CLI::Scaffold::Source
|
|
|
108
108
|
# @rbs return: String
|
|
109
109
|
def ruby: (untyped value) -> String
|
|
110
110
|
|
|
111
|
+
# Ruby source for a value in the shared style: a String or a quoted Symbol in
|
|
112
|
+
# single quotes, unless it holds a quote, a backslash or a character only an
|
|
113
|
+
# escape can write, which double quotes are for.
|
|
114
|
+
# @rbs value: untyped
|
|
115
|
+
# @rbs return: String
|
|
116
|
+
def literal: (untyped value) -> String
|
|
117
|
+
|
|
118
|
+
# @rbs text: String
|
|
119
|
+
# @rbs return: bool
|
|
120
|
+
def single_quotable?: (String text) -> bool
|
|
121
|
+
|
|
111
122
|
# A foreign key a class declares is on one column, and refers to the
|
|
112
123
|
# primary key of the table it references.
|
|
113
124
|
# @rbs constraint: Skyward::ORM::Catalog::Constraint
|
|
@@ -17,13 +17,15 @@ class Skyward::ORM::Connection::Instrumented
|
|
|
17
17
|
|
|
18
18
|
# @rbs sql: String
|
|
19
19
|
# @rbs binds: Array[untyped]
|
|
20
|
+
# @rbs prepare: bool
|
|
20
21
|
# @rbs return: Array[Array[untyped]]
|
|
21
|
-
def execute: (String sql, ?Array[untyped] binds) -> Array[Array[untyped]]
|
|
22
|
+
def execute: (String sql, ?Array[untyped] binds, ?prepare: bool) -> Array[Array[untyped]]
|
|
22
23
|
|
|
23
24
|
# @rbs sql: String
|
|
24
25
|
# @rbs *binds: untyped
|
|
26
|
+
# @rbs prepare: bool
|
|
25
27
|
# @rbs return: Array[Array[untyped]]
|
|
26
|
-
def execute2: (String sql, *untyped binds) -> Array[Array[untyped]]
|
|
28
|
+
def execute2: (String sql, *untyped binds, ?prepare: bool) -> Array[Array[untyped]]
|
|
27
29
|
|
|
28
30
|
# @rbs sql: String
|
|
29
31
|
# @rbs return: void
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/database/decoders.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Skyward::ORM::Database::Decoders
|
|
4
|
+
# @rbs (Class row, Array[Skyward::ORM::Tables::Column] columns, Array[Integer] positions,
|
|
5
|
+
# Skyward::ORM::_Adapter adapter) -> ^(Array[untyped]) -> untyped
|
|
6
|
+
def compile: (Class row, Array[Skyward::ORM::Tables::Column] columns, Array[Integer] positions, Skyward::ORM::_Adapter adapter) -> ^(Array[untyped]) -> untyped
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
# @rbs (Class row, Array[Skyward::ORM::Tables::Column] columns, Array[Integer] positions,
|
|
11
|
+
# Skyward::ORM::_Adapter adapter) -> String
|
|
12
|
+
def source: (Class row, Array[Skyward::ORM::Tables::Column] columns, Array[Integer] positions, Skyward::ORM::_Adapter adapter) -> String
|
|
13
|
+
|
|
14
|
+
# @rbs row: Class
|
|
15
|
+
# @rbs columns: Array[Skyward::ORM::Tables::Column]
|
|
16
|
+
# @rbs values: Array[String]
|
|
17
|
+
# @rbs return: String
|
|
18
|
+
def construction: (Class row, Array[Skyward::ORM::Tables::Column] columns, Array[String] values) -> String
|
|
19
|
+
end
|
|
@@ -37,27 +37,38 @@ class Skyward::ORM::Database
|
|
|
37
37
|
|
|
38
38
|
FOREIGN: String
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
# Each IN list's length is a shape of its own, and so is each SQL string an
|
|
41
|
+
# app builds at run time, so the cache is bounded.
|
|
42
|
+
SHAPES: Integer
|
|
41
43
|
|
|
42
|
-
@
|
|
44
|
+
@adapter: Skyward::ORM::_Adapter
|
|
43
45
|
|
|
44
|
-
@
|
|
46
|
+
@pool: Skyward::ORM::Connection::Pool
|
|
45
47
|
|
|
46
|
-
@
|
|
48
|
+
@column_types: Skyward::ORM::Tables::ColumnTypes
|
|
49
|
+
|
|
50
|
+
@tables: Array[Skyward::ORM::Catalog::Table]
|
|
47
51
|
|
|
48
52
|
@check: bool
|
|
49
53
|
|
|
50
|
-
@
|
|
54
|
+
@checked: Set[singleton(Skyward::ORM::Record)]
|
|
51
55
|
|
|
52
|
-
@
|
|
56
|
+
@lock: Thread::Mutex
|
|
53
57
|
|
|
54
|
-
@
|
|
58
|
+
@decoders: Hash[[ singleton(Skyward::ORM::Record), Class, Array[Symbol] ], ^(Array[untyped]) -> untyped]
|
|
55
59
|
|
|
56
|
-
@
|
|
60
|
+
@sql: Hash[untyped, String]
|
|
61
|
+
|
|
62
|
+
@query_decoders: Hash[[ Class, Array[Symbol] ], ^(Array[untyped]) -> untyped]
|
|
63
|
+
|
|
64
|
+
@key: Symbol
|
|
65
|
+
|
|
66
|
+
@prepared_statements: bool
|
|
57
67
|
|
|
58
68
|
# @rbs (Skyward::ORM::_Adapter adapter, Skyward::ORM::Connection::Pool pool,
|
|
59
|
-
# Skyward::ORM::Tables::ColumnTypes column_types, Array[Skyward::ORM::Catalog::Table] tables, check: bool
|
|
60
|
-
|
|
69
|
+
# Skyward::ORM::Tables::ColumnTypes column_types, Array[Skyward::ORM::Catalog::Table] tables, check: bool,
|
|
70
|
+
# ?prepared_statements: bool) -> void
|
|
71
|
+
def initialize: (Skyward::ORM::_Adapter adapter, Skyward::ORM::Connection::Pool pool, Skyward::ORM::Tables::ColumnTypes column_types, Array[Skyward::ORM::Catalog::Table] tables, check: bool, ?prepared_statements: bool) -> void
|
|
61
72
|
|
|
62
73
|
# The seam every query runs through. Fiber storage is copied into child
|
|
63
74
|
# fibers and threads, so one can find a transaction here that isn't its own.
|
|
@@ -106,6 +117,14 @@ class Skyward::ORM::Database
|
|
|
106
117
|
# @rbs return: ^(Array[untyped]) -> untyped
|
|
107
118
|
def decoder: (singleton(Skyward::ORM::Record) table, Class row, Array[Symbol] expressed) -> ^(Array[untyped]) -> untyped
|
|
108
119
|
|
|
120
|
+
# The cache is replaced under the lock rather than changed, so a hit reads
|
|
121
|
+
# it without one, on every Ruby. A miss renders outside the lock, so two
|
|
122
|
+
# fibers may render one shape, and the SQL the first adds is the one kept.
|
|
123
|
+
# @rbs key: untyped
|
|
124
|
+
# @rbs &: () -> String
|
|
125
|
+
# @rbs return: String
|
|
126
|
+
def cached_sql: (untyped key) { () -> String } -> String
|
|
127
|
+
|
|
109
128
|
# Every query and write calls this before it touches its table, so a table
|
|
110
129
|
# class loaded after connect is checked before its first use.
|
|
111
130
|
# @rbs table: singleton(Skyward::ORM::Record)
|
|
@@ -122,8 +141,6 @@ class Skyward::ORM::Database
|
|
|
122
141
|
# @rbs return: Array[Hash[Symbol, untyped]]
|
|
123
142
|
def hashes: (String sql, Array[untyped] values) -> Array[Hash[Symbol, untyped]]
|
|
124
143
|
|
|
125
|
-
# Raw SQL picks its own columns, in its own order, so they're matched to the
|
|
126
|
-
# row class's members by name.
|
|
127
144
|
# @rbs row: Class
|
|
128
145
|
# @rbs sql: String
|
|
129
146
|
# @rbs values: Array[untyped]
|
|
@@ -163,6 +180,13 @@ class Skyward::ORM::Database
|
|
|
163
180
|
# @rbs [T] () { (Skyward::ORM::_Connection connection) -> T } -> T
|
|
164
181
|
def changing: [T] () { (Skyward::ORM::_Connection connection) -> T } -> T
|
|
165
182
|
|
|
183
|
+
# Dropping the oldest, rather than the least recently used, leaves a hit
|
|
184
|
+
# nothing to change.
|
|
185
|
+
# @rbs key: untyped
|
|
186
|
+
# @rbs sql: String
|
|
187
|
+
# @rbs return: String
|
|
188
|
+
def cache_sql: (untyped key, String sql) -> String
|
|
189
|
+
|
|
166
190
|
# @rbs held: Held
|
|
167
191
|
# @rbs return: bool
|
|
168
192
|
def owned?: (Held held) -> bool
|
|
@@ -207,9 +231,9 @@ class Skyward::ORM::Database
|
|
|
207
231
|
def build: (singleton(Skyward::ORM::Record) table, Class row, Array[Symbol] expressed) -> ^(Array[untyped]) -> untyped
|
|
208
232
|
|
|
209
233
|
# @rbs row: Class
|
|
210
|
-
# @rbs columns: Array[
|
|
234
|
+
# @rbs columns: Array[Symbol]
|
|
211
235
|
# @rbs return: ^(Array[untyped]) -> untyped
|
|
212
|
-
def
|
|
236
|
+
def query_decoder: (Class row, Array[Symbol] columns) -> ^(Array[untyped]) -> untyped
|
|
213
237
|
|
|
214
238
|
# Raw SQL returns rows, with no room for a violation, so one raises.
|
|
215
239
|
# @rbs sql: String
|
|
@@ -85,6 +85,19 @@ module Skyward::ORM::Queries::Clauses[R]
|
|
|
85
85
|
def members: () -> [ :keyword, :table, :on ]
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
class InList < Data
|
|
89
|
+
attr_reader placeholders(): Integer
|
|
90
|
+
|
|
91
|
+
attr_reader null(): bool
|
|
92
|
+
|
|
93
|
+
def self.new: (Integer placeholders, bool null) -> instance
|
|
94
|
+
| (placeholders: Integer, null: bool) -> instance
|
|
95
|
+
|
|
96
|
+
def self.members: () -> [ :placeholders, :null ]
|
|
97
|
+
|
|
98
|
+
def members: () -> [ :placeholders, :null ]
|
|
99
|
+
end
|
|
100
|
+
|
|
88
101
|
@offset: Integer?
|
|
89
102
|
|
|
90
103
|
@limit: Integer?
|
|
@@ -293,11 +306,45 @@ module Skyward::ORM::Queries::Clauses[R]
|
|
|
293
306
|
# @rbs return: [String, Array[untyped]]
|
|
294
307
|
def statement: (Skyward::ORM::Database database, Array[[ Symbol, direction ]] orders, Integer? limit) -> [ String, Array[untyped] ]
|
|
295
308
|
|
|
309
|
+
# The SQL is rendered from the conditions' shapes, not the conditions, so
|
|
310
|
+
# two queries that share a key can't render different SQL.
|
|
296
311
|
# @rbs database: Skyward::ORM::Database
|
|
312
|
+
# @rbs kind: Symbol | Array[untyped]
|
|
297
313
|
# @rbs orders: Array[[Symbol, direction]]
|
|
298
314
|
# @rbs limit: Integer?
|
|
315
|
+
# @rbs &: (String from) -> String
|
|
299
316
|
# @rbs return: [String, Array[untyped]]
|
|
300
|
-
def
|
|
317
|
+
def selecting: (Skyward::ORM::Database database, Symbol | Array[untyped] kind, Array[[ Symbol, direction ]] orders, Integer? limit) { (String from) -> String } -> [ String, Array[untyped] ]
|
|
318
|
+
|
|
319
|
+
# The binds follow the order in which from numbers their placeholders.
|
|
320
|
+
# @rbs database: Skyward::ORM::Database
|
|
321
|
+
# @rbs return: [Array[condition], Array[untyped]]
|
|
322
|
+
def bound: (Skyward::ORM::Database database) -> [ Array[condition], Array[untyped] ]
|
|
323
|
+
|
|
324
|
+
# @rbs adapter: Skyward::ORM::_Adapter
|
|
325
|
+
# @rbs columns: Hash[Symbol, Skyward::ORM::Tables::Column]
|
|
326
|
+
# @rbs conditions: Array[condition]
|
|
327
|
+
# @rbs return: [Array[condition], Array[untyped]]
|
|
328
|
+
def shaped: (Skyward::ORM::_Adapter adapter, Hash[Symbol, Skyward::ORM::Tables::Column] columns, Array[condition] conditions) -> [ Array[condition], Array[untyped] ]
|
|
329
|
+
|
|
330
|
+
# @rbs adapter: Skyward::ORM::_Adapter
|
|
331
|
+
# @rbs columns: Hash[Symbol, Skyward::ORM::Tables::Column]
|
|
332
|
+
# @rbs condition: condition
|
|
333
|
+
# @rbs return: [condition, Array[untyped]]
|
|
334
|
+
def shape: (Skyward::ORM::_Adapter adapter, Hash[Symbol, Skyward::ORM::Tables::Column] columns, condition condition) -> [ condition, Array[untyped] ]
|
|
335
|
+
|
|
336
|
+
# @rbs adapter: Skyward::ORM::_Adapter
|
|
337
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
338
|
+
# @rbs comparison: Comparison
|
|
339
|
+
# @rbs return: [Comparison, Array[untyped]]
|
|
340
|
+
def compared: (Skyward::ORM::_Adapter adapter, Skyward::ORM::Tables::Column column, Comparison comparison) -> [ Comparison, Array[untyped] ]
|
|
341
|
+
|
|
342
|
+
# @rbs database: Skyward::ORM::Database
|
|
343
|
+
# @rbs shapes: Array[condition]
|
|
344
|
+
# @rbs orders: Array[[Symbol, direction]]
|
|
345
|
+
# @rbs limit: Integer?
|
|
346
|
+
# @rbs return: String
|
|
347
|
+
def from: (Skyward::ORM::Database database, Array[condition] shapes, Array[[ Symbol, direction ]] orders, Integer? limit) -> String
|
|
301
348
|
|
|
302
349
|
# @rbs join: Join
|
|
303
350
|
# @rbs return: String
|
|
@@ -306,57 +353,57 @@ module Skyward::ORM::Queries::Clauses[R]
|
|
|
306
353
|
# An UPDATE binds its SET values first, so its WHERE's numbered placeholders
|
|
307
354
|
# start after them.
|
|
308
355
|
# @rbs database: Skyward::ORM::Database
|
|
356
|
+
# @rbs shapes: Array[condition]
|
|
309
357
|
# @rbs position: Integer
|
|
310
|
-
# @rbs return: [String?,
|
|
311
|
-
def filter: (Skyward::ORM::Database database, Integer position) -> [ String?,
|
|
358
|
+
# @rbs return: [String?, Integer]
|
|
359
|
+
def filter: (Skyward::ORM::Database database, Array[condition] shapes, Integer position) -> [ String?, Integer ]
|
|
312
360
|
|
|
313
361
|
# @rbs database: Skyward::ORM::Database
|
|
314
|
-
# @rbs
|
|
362
|
+
# @rbs shapes: Array[condition]
|
|
315
363
|
# @rbs position: Integer
|
|
316
|
-
# @rbs return: [String,
|
|
317
|
-
def conjunction: (Skyward::ORM::Database database, Array[condition]
|
|
364
|
+
# @rbs return: [String, Integer]
|
|
365
|
+
def conjunction: (Skyward::ORM::Database database, Array[condition] shapes, Integer position) -> [ String, Integer ]
|
|
318
366
|
|
|
319
367
|
# @rbs database: Skyward::ORM::Database
|
|
320
|
-
# @rbs
|
|
368
|
+
# @rbs shape: condition
|
|
321
369
|
# @rbs position: Integer
|
|
322
|
-
# @rbs return: [String,
|
|
323
|
-
def render: (Skyward::ORM::Database database, condition
|
|
370
|
+
# @rbs return: [String, Integer]
|
|
371
|
+
def render: (Skyward::ORM::Database database, condition shape, Integer position) -> [ String, Integer ]
|
|
324
372
|
|
|
325
373
|
# @rbs database: Skyward::ORM::Database
|
|
326
374
|
# @rbs comparison: Comparison
|
|
327
375
|
# @rbs position: Integer
|
|
328
|
-
# @rbs return: [String,
|
|
329
|
-
def comparison: (Skyward::ORM::Database database, Comparison comparison, Integer position) -> [ String,
|
|
376
|
+
# @rbs return: [String, Integer]
|
|
377
|
+
def comparison: (Skyward::ORM::Database database, Comparison comparison, Integer position) -> [ String, Integer ]
|
|
330
378
|
|
|
331
|
-
# @rbs
|
|
379
|
+
# @rbs adapter: Skyward::ORM::_Adapter
|
|
332
380
|
# @rbs fragment: Fragment
|
|
333
381
|
# @rbs position: Integer
|
|
334
|
-
# @rbs return: [String,
|
|
335
|
-
def fragment: (Skyward::ORM::
|
|
382
|
+
# @rbs return: [String, Integer]
|
|
383
|
+
def fragment: (Skyward::ORM::_Adapter adapter, Fragment fragment, Integer position) -> [ String, Integer ]
|
|
336
384
|
|
|
337
385
|
# NOT of an unknown is unknown, so a row whose column is NULL would be left
|
|
338
386
|
# out, though it doesn't match. An untyped column may hold NULL, and an SQL
|
|
339
387
|
# string's columns can't be known.
|
|
340
388
|
# @rbs database: Skyward::ORM::Database
|
|
341
|
-
# @rbs
|
|
389
|
+
# @rbs shapes: Array[condition]
|
|
342
390
|
# @rbs position: Integer
|
|
343
|
-
# @rbs return: [String,
|
|
344
|
-
def negation: (Skyward::ORM::Database database, Array[condition]
|
|
391
|
+
# @rbs return: [String, Integer]
|
|
392
|
+
def negation: (Skyward::ORM::Database database, Array[condition] shapes, Integer position) -> [ String, Integer ]
|
|
345
393
|
|
|
346
394
|
# @rbs database: Skyward::ORM::Database
|
|
347
|
-
# @rbs
|
|
395
|
+
# @rbs shapes: Array[condition]
|
|
348
396
|
# @rbs position: Integer
|
|
349
|
-
# @rbs return: [String,
|
|
350
|
-
def alternative: (Skyward::ORM::Database database, Array[condition]
|
|
397
|
+
# @rbs return: [String, Integer]
|
|
398
|
+
def alternative: (Skyward::ORM::Database database, Array[condition] shapes, Integer position) -> [ String, Integer ]
|
|
351
399
|
|
|
352
400
|
# PostgreSQL refuses an empty IN (), and IN never matches NULL.
|
|
353
401
|
# @rbs adapter: Skyward::ORM::_Adapter
|
|
354
|
-
# @rbs column: Skyward::ORM::Tables::Column
|
|
355
402
|
# @rbs name: String
|
|
356
|
-
# @rbs
|
|
403
|
+
# @rbs list: InList
|
|
357
404
|
# @rbs position: Integer
|
|
358
|
-
# @rbs return: [String,
|
|
359
|
-
def within: (Skyward::ORM::_Adapter adapter,
|
|
405
|
+
# @rbs return: [String, Integer]
|
|
406
|
+
def within: (Skyward::ORM::_Adapter adapter, String name, InList list, Integer position) -> [ String, Integer ]
|
|
360
407
|
|
|
361
408
|
# Steep can't tie the row class to R, so the rows are untyped here and each
|
|
362
409
|
# public method types them.
|
|
@@ -386,17 +433,23 @@ module Skyward::ORM::Queries::Clauses[R]
|
|
|
386
433
|
def qualified: (Symbol name, ?singleton(Skyward::ORM::Record) table) -> String
|
|
387
434
|
|
|
388
435
|
# @rbs values: Hash[Symbol, untyped]
|
|
436
|
+
# @rbs returned_row: Class?
|
|
389
437
|
# @rbs return: [String, Array[untyped]]
|
|
390
|
-
def updating: (Hash[Symbol, untyped] values) -> [ String, Array[untyped] ]
|
|
438
|
+
def updating: (Hash[Symbol, untyped] values, Class? returned_row) -> [ String, Array[untyped] ]
|
|
391
439
|
|
|
440
|
+
# @rbs returned_row: Class?
|
|
392
441
|
# @rbs return: [String, Array[untyped]]
|
|
393
|
-
def deleting: () -> [ String, Array[untyped] ]
|
|
442
|
+
def deleting: (Class? returned_row) -> [ String, Array[untyped] ]
|
|
394
443
|
|
|
444
|
+
# require_writable leaves a write no clause but its conditions, so they and
|
|
445
|
+
# what it sets and returns are its shape.
|
|
395
446
|
# @rbs method: Symbol
|
|
396
|
-
# @rbs
|
|
447
|
+
# @rbs columns: Array[Symbol]
|
|
397
448
|
# @rbs set: Array[untyped]
|
|
449
|
+
# @rbs returned_row: Class?
|
|
450
|
+
# @rbs &: () -> String
|
|
398
451
|
# @rbs return: [String, Array[untyped]]
|
|
399
|
-
def changing: (Symbol method,
|
|
452
|
+
def changing: (Symbol method, Array[Symbol] columns, Array[untyped] set, Class? returned_row) { () -> String } -> [ String, Array[untyped] ]
|
|
400
453
|
|
|
401
454
|
# @rbs [T] (T | Skyward::ORM::Violation written) -> T
|
|
402
455
|
def unviolated: [T] (T | Skyward::ORM::Violation written) -> T
|
|
@@ -5,8 +5,14 @@ class Skyward::ORM::Record
|
|
|
5
5
|
|
|
6
6
|
private def initialize_columns: (Hash[Symbol, untyped] columns) -> void
|
|
7
7
|
|
|
8
|
+
private def load_columns: (*untyped values) -> self
|
|
9
|
+
|
|
8
10
|
def to_h: () -> Hash[Symbol, untyped]
|
|
9
11
|
|
|
12
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
|
13
|
+
|
|
14
|
+
def inspect: () -> String
|
|
15
|
+
|
|
10
16
|
def ==: (untyped other) -> bool
|
|
11
17
|
|
|
12
18
|
def eql?: (untyped other) -> bool
|
|
@@ -78,11 +84,4 @@ class Skyward::ORM::Record
|
|
|
78
84
|
# @rbs **changes: untyped
|
|
79
85
|
# @rbs return: self
|
|
80
86
|
def with: (**untyped changes) -> self
|
|
81
|
-
|
|
82
|
-
# @rbs keys: Array[Symbol]?
|
|
83
|
-
# @rbs return: Hash[Symbol, untyped]
|
|
84
|
-
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
|
85
|
-
|
|
86
|
-
# @rbs return: String
|
|
87
|
-
def inspect: () -> String
|
|
88
87
|
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# Generated from lib/skyward/orm/statements.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
module Skyward::ORM::Statements
|
|
4
|
-
# @rbs
|
|
5
|
-
# @rbs column_types: Skyward::ORM::Tables::ColumnTypes
|
|
6
|
-
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
4
|
+
# @rbs database: Skyward::ORM::Database
|
|
7
5
|
# @rbs table: singleton(Skyward::ORM::Record)
|
|
8
6
|
# @rbs values: Hash[Symbol, untyped]
|
|
7
|
+
# @rbs returned_row: Class?
|
|
9
8
|
# @rbs return: [String, Array[untyped]]
|
|
10
|
-
def insert: (Skyward::ORM::
|
|
9
|
+
def insert: (Skyward::ORM::Database database, singleton(Skyward::ORM::Record) table, Hash[Symbol, untyped] values, Class? returned_row) -> [ String, Array[untyped] ]
|
|
11
10
|
|
|
12
11
|
# @rbs adapter: Skyward::ORM::_Adapter
|
|
13
12
|
# @rbs column_types: Skyward::ORM::Tables::ColumnTypes
|
|
@@ -57,9 +56,9 @@ module Skyward::ORM::Statements
|
|
|
57
56
|
# @rbs return: Hash[Symbol, Skyward::ORM::Tables::Column]
|
|
58
57
|
def by_name: (Skyward::ORM::Tables::ColumnTypes column_types, singleton(Skyward::ORM::Record) table) -> Hash[Symbol, Skyward::ORM::Tables::Column]
|
|
59
58
|
|
|
60
|
-
# @rbs
|
|
59
|
+
# @rbs row: Class
|
|
61
60
|
# @rbs return: String
|
|
62
|
-
def returning: (
|
|
61
|
+
def returning: (Class row) -> String
|
|
63
62
|
|
|
64
63
|
# Quoted, so a column named order or user is still a column.
|
|
65
64
|
# @rbs name: Symbol
|
|
@@ -74,12 +73,11 @@ module Skyward::ORM::Statements
|
|
|
74
73
|
def exact: (Skyward::ORM::Tables::column_type? type, untyped value) -> untyped
|
|
75
74
|
|
|
76
75
|
# @rbs adapter: Skyward::ORM::_Adapter
|
|
77
|
-
# @rbs column_types: Skyward::ORM::Tables::ColumnTypes
|
|
78
76
|
# @rbs table: singleton(Skyward::ORM::Record)
|
|
79
77
|
# @rbs columns: Array[Symbol]
|
|
80
|
-
# @rbs rows:
|
|
81
|
-
# @rbs return:
|
|
82
|
-
def
|
|
78
|
+
# @rbs rows: Integer
|
|
79
|
+
# @rbs return: String
|
|
80
|
+
def insertion: (Skyward::ORM::_Adapter adapter, singleton(Skyward::ORM::Record) table, Array[Symbol] columns, Integer rows) -> String
|
|
83
81
|
|
|
84
82
|
# @rbs table: singleton(Skyward::ORM::Record)
|
|
85
83
|
# @rbs columns: Array[Symbol]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Skyward::ORM::Tables::Rows
|
|
4
4
|
METHODS: Array[Symbol]
|
|
5
5
|
|
|
6
|
-
# Each row sets, compares and hashes its columns' instance variables
|
|
6
|
+
# Each row sets, reads, compares and hashes its columns' instance variables
|
|
7
7
|
# directly, rather than reflecting on them for every row.
|
|
8
8
|
# @rbs columns: Array[Symbol]
|
|
9
9
|
# @rbs return: String
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Skyward
|
|
4
4
|
# @rbs (String url, ?signatures: String, ?pool: Integer, ?check: bool, ?default: bool,
|
|
5
|
-
# ?instrument: ORM::_Instrument?) -> ORM::Database
|
|
6
|
-
def self.connect: (String url, ?signatures: String, ?pool: Integer, ?check: bool, ?default: bool, ?instrument: ORM::_Instrument?) -> ORM::Database
|
|
5
|
+
# ?instrument: ORM::_Instrument?, ?prepared_statements: bool) -> ORM::Database
|
|
6
|
+
def self.connect: (String url, ?signatures: String, ?pool: Integer, ?check: bool, ?default: bool, ?instrument: ORM::_Instrument?, ?prepared_statements: bool) -> ORM::Database
|
|
7
7
|
|
|
8
8
|
# @rbs [T] (ORM::Database database) { () -> T } -> T
|
|
9
9
|
def self.using: [T] (ORM::Database database) { () -> T } -> T
|
data/sig/manual/pg.rbs
CHANGED
|
@@ -6,6 +6,7 @@ module PG
|
|
|
6
6
|
PG_DIAG_TABLE_NAME: Integer
|
|
7
7
|
PG_DIAG_COLUMN_NAME: Integer
|
|
8
8
|
PG_DIAG_CONSTRAINT_NAME: Integer
|
|
9
|
+
PG_DIAG_SOURCE_FUNCTION: Integer
|
|
9
10
|
PQTRANS_IDLE: Integer
|
|
10
11
|
|
|
11
12
|
def self.connect: (String url) -> Connection
|
|
@@ -13,6 +14,9 @@ module PG
|
|
|
13
14
|
class Connection
|
|
14
15
|
def exec: (String sql) -> Result
|
|
15
16
|
def exec_params: [T] (String sql, Array[untyped] params) { (Result result) -> T } -> T
|
|
17
|
+
def prepare: (String name, String sql) -> Result
|
|
18
|
+
def exec_prepared: [T] (String name, Array[untyped] params) { (Result result) -> T } -> T
|
|
19
|
+
def close_prepared: (String name) -> Result
|
|
16
20
|
def transaction_status: () -> Integer
|
|
17
21
|
def close: () -> void
|
|
18
22
|
end
|
|
@@ -29,6 +33,12 @@ module PG
|
|
|
29
33
|
def result: () -> Result?
|
|
30
34
|
end
|
|
31
35
|
|
|
36
|
+
class FeatureNotSupported < Error
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class InvalidSqlStatementName < Error
|
|
40
|
+
end
|
|
41
|
+
|
|
32
42
|
module TextEncoder
|
|
33
43
|
class Array
|
|
34
44
|
def encode: (::Array[untyped] value) -> String
|
data/sig/manual/skyward/orm.rbs
CHANGED
|
@@ -5,11 +5,14 @@ module Skyward::ORM
|
|
|
5
5
|
type int32 = Integer
|
|
6
6
|
type int16 = Integer
|
|
7
7
|
|
|
8
|
-
# Each adapter's connection
|
|
8
|
+
# Each adapter's connection, Adapters::SQLite::Connection and
|
|
9
|
+
# Adapters::PostgreSQL::Connection, and Connection::Instrumented, which wraps
|
|
10
|
+
# either. prepare: keeps the statement on the connection to run again, unless
|
|
11
|
+
# it binds more than StatementCache::MAX_BINDS values.
|
|
9
12
|
interface _Connection
|
|
10
|
-
def execute: (String sql, ?Array[untyped] binds) -> Array[Array[untyped]]
|
|
13
|
+
def execute: (String sql, ?Array[untyped] binds, ?prepare: bool) -> Array[Array[untyped]]
|
|
11
14
|
# Its first row is the result's column names, even when it has no rows.
|
|
12
|
-
def execute2: (String sql, *untyped binds) -> Array[Array[untyped]]
|
|
15
|
+
def execute2: (String sql, *untyped binds, ?prepare: bool) -> Array[Array[untyped]]
|
|
13
16
|
def execute_batch: (String sql) -> void
|
|
14
17
|
# The rows the latest INSERT, UPDATE or DELETE that execute ran changed.
|
|
15
18
|
def changes: () -> Integer
|
|
@@ -50,6 +53,9 @@ module Skyward::ORM
|
|
|
50
53
|
def encode: (untyped value) -> untyped
|
|
51
54
|
# An Array column's value, each item encoded as the adapter stores its type.
|
|
52
55
|
def encode_array: (Array[untyped] items) -> String
|
|
56
|
+
# Ruby that decodes the non-nil value the Ruby expression value names,
|
|
57
|
+
# which a row's decoder inlines and decode runs.
|
|
58
|
+
def decoding: (Tables::Column column, String value) -> String
|
|
53
59
|
def decode: (Tables::Column column, untyped value) -> untyped
|
|
54
60
|
def tables: (_Connection connection) -> Array[Catalog::Table]
|
|
55
61
|
def violation: (StandardError error, Array[Catalog::Table] tables, Symbol? table) -> Violation?
|
data/sig/manual/sqlite3.rbs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
# classify a violation, extended_result_codes=, which turns those codes on,
|
|
3
3
|
# busy_handler_timeout=, which waits on a lock without holding the GVL,
|
|
4
4
|
# execute2, which returns a result's column names, execute_batch, which runs a
|
|
5
|
-
# migration,
|
|
6
|
-
# connection that comes back mid-transaction, and closes one it can't roll back
|
|
5
|
+
# migration, transaction_active? and close, with which the pool finds a
|
|
6
|
+
# connection that comes back mid-transaction, and closes one it can't roll back,
|
|
7
|
+
# and prepare and the Statement it returns, which a connection keeps to run again.
|
|
7
8
|
module SQLite3
|
|
8
9
|
class Exception < ::StandardError
|
|
9
10
|
def code: () -> Integer
|
|
@@ -18,6 +19,16 @@ module SQLite3
|
|
|
18
19
|
def execute2: (String sql, *untyped bind_vars) -> Array[Array[untyped]]
|
|
19
20
|
def execute_batch: (String sql) -> void
|
|
20
21
|
def transaction_active?: () -> bool
|
|
22
|
+
def prepare: (String sql) -> Statement
|
|
23
|
+
def close: () -> void
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Statement
|
|
27
|
+
def bind_params: (*untyped bind_vars) -> void
|
|
28
|
+
def to_a: () -> Array[Array[untyped]]
|
|
29
|
+
def column_count: () -> Integer
|
|
30
|
+
def column_name: (Integer index) -> String
|
|
31
|
+
def reset!: () -> void
|
|
21
32
|
def close: () -> void
|
|
22
33
|
end
|
|
23
34
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: skyward-orm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jake Bottrall
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.4.
|
|
18
|
+
version: 0.4.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.4.
|
|
25
|
+
version: 0.4.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: bigdecimal
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -57,13 +57,16 @@ executables: []
|
|
|
57
57
|
extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
|
59
59
|
files:
|
|
60
|
+
- LICENSE
|
|
60
61
|
- README.md
|
|
61
62
|
- lib/skyward/orm.rb
|
|
62
63
|
- lib/skyward/orm/adapters.rb
|
|
63
64
|
- lib/skyward/orm/adapters/postgresql.rb
|
|
64
65
|
- lib/skyward/orm/adapters/postgresql/connection.rb
|
|
65
66
|
- lib/skyward/orm/adapters/sqlite.rb
|
|
67
|
+
- lib/skyward/orm/adapters/sqlite/connection.rb
|
|
66
68
|
- lib/skyward/orm/adapters/sqlite/constraints.rb
|
|
69
|
+
- lib/skyward/orm/adapters/statement_cache.rb
|
|
67
70
|
- lib/skyward/orm/catalog.rb
|
|
68
71
|
- lib/skyward/orm/catalog/column.rb
|
|
69
72
|
- lib/skyward/orm/catalog/constraint.rb
|
|
@@ -83,6 +86,7 @@ files:
|
|
|
83
86
|
- lib/skyward/orm/connection/pool.rb
|
|
84
87
|
- lib/skyward/orm/connection/session.rb
|
|
85
88
|
- lib/skyward/orm/database.rb
|
|
89
|
+
- lib/skyward/orm/database/decoders.rb
|
|
86
90
|
- lib/skyward/orm/database/schema_check.rb
|
|
87
91
|
- lib/skyward/orm/execution.rb
|
|
88
92
|
- lib/skyward/orm/migration_error.rb
|
|
@@ -149,7 +153,9 @@ files:
|
|
|
149
153
|
- sig/generated/skyward/orm/adapters/postgresql.rbs
|
|
150
154
|
- sig/generated/skyward/orm/adapters/postgresql/connection.rbs
|
|
151
155
|
- sig/generated/skyward/orm/adapters/sqlite.rbs
|
|
156
|
+
- sig/generated/skyward/orm/adapters/sqlite/connection.rbs
|
|
152
157
|
- sig/generated/skyward/orm/adapters/sqlite/constraints.rbs
|
|
158
|
+
- sig/generated/skyward/orm/adapters/statement_cache.rbs
|
|
153
159
|
- sig/generated/skyward/orm/catalog.rbs
|
|
154
160
|
- sig/generated/skyward/orm/catalog/column.rbs
|
|
155
161
|
- sig/generated/skyward/orm/catalog/constraint.rbs
|
|
@@ -169,6 +175,7 @@ files:
|
|
|
169
175
|
- sig/generated/skyward/orm/connection/pool.rbs
|
|
170
176
|
- sig/generated/skyward/orm/connection/session.rbs
|
|
171
177
|
- sig/generated/skyward/orm/database.rbs
|
|
178
|
+
- sig/generated/skyward/orm/database/decoders.rbs
|
|
172
179
|
- sig/generated/skyward/orm/database/schema_check.rbs
|
|
173
180
|
- sig/generated/skyward/orm/execution.rbs
|
|
174
181
|
- sig/generated/skyward/orm/migration_error.rbs
|
|
@@ -243,6 +250,7 @@ files:
|
|
|
243
250
|
- sig/manual/skyward/orm/cli/scaffold.rbs
|
|
244
251
|
- sig/manual/skyward/orm/cli/scaffold/source.rbs
|
|
245
252
|
- sig/manual/skyward/orm/cli/status.rbs
|
|
253
|
+
- sig/manual/skyward/orm/database/decoders.rbs
|
|
246
254
|
- sig/manual/skyward/orm/database/schema_check.rbs
|
|
247
255
|
- sig/manual/skyward/orm/migrations/definitions.rbs
|
|
248
256
|
- sig/manual/skyward/orm/migrations/diff.rbs
|