skyward-orm 0.2.0 → 0.4.0
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/README.md +351 -75
- data/lib/skyward/orm/adapters/postgresql/connection.rb +52 -0
- data/lib/skyward/orm/adapters/postgresql.rb +385 -0
- data/lib/skyward/orm/adapters/sqlite/constraints.rb +190 -0
- data/lib/skyward/orm/adapters/sqlite.rb +426 -0
- data/lib/skyward/orm/adapters.rb +48 -0
- data/lib/skyward/orm/catalog/column.rb +13 -0
- data/lib/skyward/orm/catalog/constraint.rb +13 -0
- data/lib/skyward/orm/catalog/index.rb +11 -0
- data/lib/skyward/orm/catalog/table.rb +10 -0
- data/lib/skyward/orm/catalog.rb +6 -0
- data/lib/skyward/orm/cli/boot_file.rb +43 -0
- data/lib/skyward/orm/cli/migrate.rb +30 -0
- data/lib/skyward/orm/cli/migration.rb +111 -0
- data/lib/skyward/orm/cli/rollback.rb +18 -0
- data/lib/skyward/orm/cli/scaffold/source.rb +304 -0
- data/lib/skyward/orm/cli/scaffold.rb +70 -0
- data/lib/skyward/orm/cli/status.rb +38 -0
- data/lib/skyward/orm/cli.rb +4 -0
- data/lib/skyward/orm/commands.rb +76 -0
- data/lib/skyward/orm/connection/instrumented.rb +69 -0
- data/lib/skyward/orm/connection/pool.rb +102 -0
- data/lib/skyward/orm/connection/session.rb +107 -0
- data/lib/skyward/orm/connection.rb +7 -0
- data/lib/skyward/orm/database/schema_check.rb +79 -0
- data/lib/skyward/orm/database.rb +357 -0
- data/lib/skyward/orm/execution.rb +9 -0
- data/lib/skyward/orm/migration_error.rb +4 -0
- data/lib/skyward/orm/migrations/add_column.rb +7 -0
- data/lib/skyward/orm/migrations/add_constraint.rb +7 -0
- data/lib/skyward/orm/migrations/add_index.rb +7 -0
- data/lib/skyward/orm/migrations/alter_table.rb +16 -0
- data/lib/skyward/orm/migrations/change_default.rb +9 -0
- data/lib/skyward/orm/migrations/change_nullable.rb +8 -0
- data/lib/skyward/orm/migrations/change_type.rb +9 -0
- data/lib/skyward/orm/migrations/create_table.rb +8 -0
- data/lib/skyward/orm/migrations/definitions.rb +179 -0
- data/lib/skyward/orm/migrations/diff.rb +337 -0
- data/lib/skyward/orm/migrations/directory.rb +48 -0
- data/lib/skyward/orm/migrations/discovery.rb +14 -0
- data/lib/skyward/orm/migrations/drop_column.rb +7 -0
- data/lib/skyward/orm/migrations/drop_constraint.rb +7 -0
- data/lib/skyward/orm/migrations/drop_index.rb +7 -0
- data/lib/skyward/orm/migrations/rename_column.rb +8 -0
- data/lib/skyward/orm/migrations/rename_constraint.rb +8 -0
- data/lib/skyward/orm/migrations/runner/edited.rb +7 -0
- data/lib/skyward/orm/migrations/runner/failed.rb +8 -0
- data/lib/skyward/orm/migrations/runner/irreversible.rb +7 -0
- data/lib/skyward/orm/migrations/runner/locked.rb +8 -0
- data/lib/skyward/orm/migrations/runner/migration.rb +11 -0
- data/lib/skyward/orm/migrations/runner/missing.rb +7 -0
- data/lib/skyward/orm/migrations/runner/raced.rb +7 -0
- data/lib/skyward/orm/migrations/runner.rb +237 -0
- data/lib/skyward/orm/migrations/script.rb +390 -0
- data/lib/skyward/orm/migrations/status.rb +122 -0
- data/lib/skyward/orm/migrations/summary.rb +107 -0
- data/lib/skyward/orm/migrations/versions.rb +19 -0
- data/lib/skyward/orm/migrations.rb +8 -0
- data/lib/skyward/orm/pool_timeout.rb +4 -0
- data/lib/skyward/orm/projection.rb +86 -0
- data/lib/skyward/orm/queries/clauses.rb +673 -0
- data/lib/skyward/orm/queries.rb +4 -0
- data/lib/skyward/orm/query.rb +26 -0
- data/lib/skyward/orm/record.rb +118 -0
- data/lib/skyward/orm/schema_mismatch.rb +4 -0
- data/lib/skyward/orm/statements/placeholders.rb +37 -0
- data/lib/skyward/orm/statements.rb +238 -0
- data/lib/skyward/orm/tables/check.rb +8 -0
- data/lib/skyward/orm/tables/column.rb +11 -0
- data/lib/skyward/orm/tables/column_types.rb +121 -0
- data/lib/skyward/orm/tables/declarations.rb +200 -0
- data/lib/skyward/orm/tables/length.rb +8 -0
- data/lib/skyward/orm/tables/loaded.rb +21 -0
- data/lib/skyward/orm/tables/members.rb +16 -0
- data/lib/skyward/orm/tables/reference.rb +9 -0
- data/lib/skyward/orm/tables/rows.rb +52 -0
- data/lib/skyward/orm/tables/schema.rb +14 -0
- data/lib/skyward/orm/tables/sources.rb +63 -0
- data/lib/skyward/orm/tables/sql.rb +7 -0
- data/lib/skyward/orm/tables/validation.rb +38 -0
- data/lib/skyward/orm/tables/values.rb +212 -0
- data/lib/skyward/orm/tables.rb +8 -0
- data/lib/skyward/orm/transactional.rb +18 -0
- data/lib/skyward/orm/version.rb +1 -1
- data/lib/skyward/orm/violation.rb +13 -0
- data/lib/skyward/orm/violation_error.rb +13 -0
- data/lib/skyward/orm.rb +106 -1
- data/sig/generated/skyward/orm/adapters/postgresql/connection.rbs +41 -0
- data/sig/generated/skyward/orm/adapters/postgresql.rbs +177 -0
- data/sig/generated/skyward/orm/adapters/sqlite/constraints.rbs +93 -0
- data/sig/generated/skyward/orm/adapters/sqlite.rbs +226 -0
- data/sig/generated/skyward/orm/adapters.rbs +18 -0
- data/sig/generated/skyward/orm/catalog/column.rbs +22 -0
- data/sig/generated/skyward/orm/catalog/constraint.rbs +22 -0
- data/sig/generated/skyward/orm/catalog/index.rbs +20 -0
- data/sig/generated/skyward/orm/catalog/table.rbs +20 -0
- data/sig/generated/skyward/orm/catalog.rbs +5 -0
- data/sig/generated/skyward/orm/cli/boot_file.rbs +21 -0
- data/sig/generated/skyward/orm/cli/migrate.rbs +15 -0
- data/sig/generated/skyward/orm/cli/migration.rbs +45 -0
- data/sig/generated/skyward/orm/cli/rollback.rbs +7 -0
- data/sig/generated/skyward/orm/cli/scaffold/source.rbs +147 -0
- data/sig/generated/skyward/orm/cli/scaffold.rbs +28 -0
- data/sig/generated/skyward/orm/cli/status.rbs +17 -0
- data/sig/generated/skyward/orm/cli.rbs +4 -0
- data/sig/generated/skyward/orm/commands.rbs +2 -0
- data/sig/generated/skyward/orm/connection/instrumented.rbs +45 -0
- data/sig/generated/skyward/orm/connection/pool.rbs +54 -0
- data/sig/generated/skyward/orm/connection/session.rbs +59 -0
- data/sig/generated/skyward/orm/connection.rbs +7 -0
- data/sig/generated/skyward/orm/database/schema_check.rbs +38 -0
- data/sig/generated/skyward/orm/database.rbs +225 -0
- data/sig/generated/skyward/orm/execution.rbs +18 -0
- data/sig/generated/skyward/orm/migration_error.rbs +4 -0
- data/sig/generated/skyward/orm/migrations/add_column.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/add_constraint.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/add_index.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/alter_table.rbs +28 -0
- data/sig/generated/skyward/orm/migrations/change_default.rbs +18 -0
- data/sig/generated/skyward/orm/migrations/change_nullable.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/change_type.rbs +18 -0
- data/sig/generated/skyward/orm/migrations/create_table.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/definitions.rbs +81 -0
- data/sig/generated/skyward/orm/migrations/diff.rbs +165 -0
- data/sig/generated/skyward/orm/migrations/directory.rbs +37 -0
- data/sig/generated/skyward/orm/migrations/discovery.rbs +9 -0
- data/sig/generated/skyward/orm/migrations/drop_column.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/drop_constraint.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/drop_index.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/rename_column.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/rename_constraint.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/runner/edited.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/runner/failed.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/runner/irreversible.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/runner/locked.rbs +16 -0
- data/sig/generated/skyward/orm/migrations/runner/migration.rbs +22 -0
- data/sig/generated/skyward/orm/migrations/runner/missing.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/runner/raced.rbs +14 -0
- data/sig/generated/skyward/orm/migrations/runner.rbs +78 -0
- data/sig/generated/skyward/orm/migrations/script.rbs +185 -0
- data/sig/generated/skyward/orm/migrations/status.rbs +62 -0
- data/sig/generated/skyward/orm/migrations/summary.rbs +49 -0
- data/sig/generated/skyward/orm/migrations/versions.rbs +11 -0
- data/sig/generated/skyward/orm/migrations.rbs +7 -0
- data/sig/generated/skyward/orm/pool_timeout.rbs +4 -0
- data/sig/generated/skyward/orm/projection.rbs +50 -0
- data/sig/generated/skyward/orm/queries/clauses.rbs +403 -0
- data/sig/generated/skyward/orm/queries.rbs +4 -0
- data/sig/generated/skyward/orm/query.rbs +20 -0
- data/sig/generated/skyward/orm/record.rbs +88 -0
- data/sig/generated/skyward/orm/schema_mismatch.rbs +4 -0
- data/sig/generated/skyward/orm/statements/placeholders.rbs +21 -0
- data/sig/generated/skyward/orm/statements.rbs +131 -0
- data/sig/generated/skyward/orm/tables/check.rbs +16 -0
- data/sig/generated/skyward/orm/tables/column.rbs +22 -0
- data/sig/generated/skyward/orm/tables/column_types.rbs +53 -0
- data/sig/generated/skyward/orm/tables/declarations.rbs +101 -0
- data/sig/generated/skyward/orm/tables/length.rbs +16 -0
- data/sig/generated/skyward/orm/tables/loaded.rbs +14 -0
- data/sig/generated/skyward/orm/tables/members.rbs +9 -0
- data/sig/generated/skyward/orm/tables/reference.rbs +18 -0
- data/sig/generated/skyward/orm/tables/rows.rbs +24 -0
- data/sig/generated/skyward/orm/tables/schema.rbs +28 -0
- data/sig/generated/skyward/orm/tables/sources.rbs +32 -0
- data/sig/generated/skyward/orm/tables/sql.rbs +14 -0
- data/sig/generated/skyward/orm/tables/validation.rbs +9 -0
- data/sig/generated/skyward/orm/tables/values.rbs +89 -0
- data/sig/generated/skyward/orm/tables.rbs +9 -0
- data/sig/generated/skyward/orm/transactional.rbs +11 -0
- data/sig/generated/skyward/orm/violation.rbs +22 -0
- data/sig/generated/skyward/orm/violation_error.rbs +10 -0
- data/sig/generated/skyward/orm.rbs +29 -0
- data/sig/manual/pg.rbs +43 -0
- data/sig/manual/skyward/orm/adapters/postgresql.rbs +3 -0
- data/sig/manual/skyward/orm/adapters/sqlite/constraints.rbs +3 -0
- data/sig/manual/skyward/orm/adapters/sqlite.rbs +3 -0
- data/sig/manual/skyward/orm/adapters.rbs +3 -0
- data/sig/manual/skyward/orm/cli/boot_file.rbs +3 -0
- data/sig/manual/skyward/orm/cli/migrate.rbs +3 -0
- data/sig/manual/skyward/orm/cli/migration.rbs +3 -0
- data/sig/manual/skyward/orm/cli/rollback.rbs +3 -0
- data/sig/manual/skyward/orm/cli/scaffold/source.rbs +3 -0
- data/sig/manual/skyward/orm/cli/scaffold.rbs +3 -0
- data/sig/manual/skyward/orm/cli/status.rbs +3 -0
- data/sig/manual/skyward/orm/database/schema_check.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/definitions.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/diff.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/directory.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/discovery.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/runner.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/script.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/status.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/summary.rbs +3 -0
- data/sig/manual/skyward/orm/migrations/versions.rbs +3 -0
- data/sig/manual/skyward/orm/statements/placeholders.rbs +3 -0
- data/sig/manual/skyward/orm/statements.rbs +3 -0
- data/sig/manual/skyward/orm/tables/loaded.rbs +3 -0
- data/sig/manual/skyward/orm/tables/members.rbs +3 -0
- data/sig/manual/skyward/orm/tables/rows.rbs +3 -0
- data/sig/manual/skyward/orm/tables/sources.rbs +3 -0
- data/sig/manual/skyward/orm/tables/validation.rbs +3 -0
- data/sig/manual/skyward/orm/tables/values.rbs +3 -0
- data/sig/manual/skyward/orm.rbs +72 -0
- data/sig/manual/sqlite3.rbs +23 -0
- metadata +217 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Skyward::ORM
|
|
4
|
+
# @rbs!
|
|
5
|
+
# type violation_kind = :unique | :foreign_key | :not_null | :check
|
|
6
|
+
|
|
7
|
+
Violation = Data.define(
|
|
8
|
+
:kind, #: violation_kind
|
|
9
|
+
:constraint, #: String?
|
|
10
|
+
:columns, #: Array[Symbol]
|
|
11
|
+
:message #: String
|
|
12
|
+
)
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Skyward::ORM::ViolationError < StandardError
|
|
4
|
+
# @dynamic violation
|
|
5
|
+
attr_reader :violation #: Skyward::ORM::Violation
|
|
6
|
+
|
|
7
|
+
# @rbs violation: Skyward::ORM::Violation
|
|
8
|
+
# @rbs return: void
|
|
9
|
+
def initialize(violation)
|
|
10
|
+
super(violation.message)
|
|
11
|
+
@violation = violation
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/skyward/orm.rb
CHANGED
|
@@ -1,11 +1,116 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "bigdecimal"
|
|
4
|
+
require "date"
|
|
5
|
+
require "json"
|
|
3
6
|
require "skyward/core"
|
|
4
7
|
require "zeitwerk"
|
|
5
8
|
require_relative "orm/version"
|
|
6
9
|
|
|
7
10
|
loader = Zeitwerk::Loader.for_gem_extension(Skyward)
|
|
8
|
-
loader.inflector.inflect(
|
|
11
|
+
loader.inflector.inflect(
|
|
12
|
+
"orm" => "ORM", "sql" => "SQL", "sqlite" => "SQLite", "postgresql" => "PostgreSQL", "cli" => "CLI"
|
|
13
|
+
)
|
|
9
14
|
# The skyward executable loads it, and it defines no constant.
|
|
10
15
|
loader.ignore("#{__dir__}/orm/commands.rb")
|
|
11
16
|
loader.setup
|
|
17
|
+
|
|
18
|
+
# An app's signatures subclass Skyward::ORM::Record, so RBS needs its declaration.
|
|
19
|
+
dir = __dir__ #: String
|
|
20
|
+
Skyward::Core::Signatures.register(File.expand_path("../../sig", dir))
|
|
21
|
+
|
|
22
|
+
module Skyward
|
|
23
|
+
# @rbs (String url, ?signatures: String, ?pool: Integer, ?check: bool, ?default: bool,
|
|
24
|
+
# ?instrument: ORM::_Instrument?) -> ORM::Database
|
|
25
|
+
def self.connect(
|
|
26
|
+
url,
|
|
27
|
+
signatures: "sig",
|
|
28
|
+
pool: 5,
|
|
29
|
+
check: ORM::Connection::SESSION.check?,
|
|
30
|
+
default: true,
|
|
31
|
+
instrument: nil
|
|
32
|
+
)
|
|
33
|
+
# Steep knows instrument is one, but untyped code can pass anything.
|
|
34
|
+
unless instrument.nil? || instrument.respond_to?(:call) # steep:ignore NoMethod
|
|
35
|
+
raise Core::BootError,
|
|
36
|
+
"Skyward.connect's instrument: takes something that responds to call, such as a lambda, " \
|
|
37
|
+
"not a #{instrument.class}" # steep:ignore NoMethod
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
reader = Core::Types::Reader.new(Core::Signatures.load(signatures), refinements: ORM::Tables::ColumnTypes::REFINEMENTS)
|
|
41
|
+
column_types = ORM::Tables::ColumnTypes.new(reader)
|
|
42
|
+
adapter, location = ORM::Adapters.resolve(
|
|
43
|
+
url,
|
|
44
|
+
schemes: ORM::Adapters::SCHEMES,
|
|
45
|
+
requirer: ->(feature) { require(feature) }
|
|
46
|
+
)
|
|
47
|
+
clock_ms = -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond) }
|
|
48
|
+
opener = lambda do
|
|
49
|
+
connection = adapter.connect(location)
|
|
50
|
+
if instrument
|
|
51
|
+
ORM::Connection::Instrumented.new(connection, instrument, adapter.adapter_name, clock_ms:)
|
|
52
|
+
else
|
|
53
|
+
connection
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
connections = ORM::Connection::Pool.new(adapter.pool_size(location, pool), opener)
|
|
57
|
+
tables = connections.with { |connection| adapter.tables(connection) }
|
|
58
|
+
database = ORM::Database.new(adapter, connections, column_types, tables, check:)
|
|
59
|
+
database.check(ORM::Tables::Loaded.table_classes(ORM::Record)) if check
|
|
60
|
+
default ? ORM::Connection::SESSION.connect(database) : database
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @rbs [T] (ORM::Database database) { () -> T } -> T
|
|
64
|
+
def self.using(database, &)
|
|
65
|
+
# Steep knows database is one, but untyped code can pass anything.
|
|
66
|
+
unless database.is_a?(ORM::Database) # steep:ignore UnreachableBranch
|
|
67
|
+
raise ArgumentError, "Skyward.using takes a database Skyward.connect returned, not a #{database.class}"
|
|
68
|
+
end
|
|
69
|
+
raise ArgumentError, "Skyward.using takes a block to run on the database" unless block_given?
|
|
70
|
+
|
|
71
|
+
ORM::Connection::SESSION.using(database, &)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# @rbs [T] () { () -> T } -> T
|
|
75
|
+
def self.transaction(&) = ORM::Connection::SESSION.database.transaction(&)
|
|
76
|
+
|
|
77
|
+
# @rbs return: bool
|
|
78
|
+
def self.transaction? = ORM::Connection::SESSION.database.transaction?
|
|
79
|
+
|
|
80
|
+
# @rbs [T] (ORM::_Row[T] row, String sql, *untyped values) -> Array[T]
|
|
81
|
+
# | (String sql, *untyped values) -> Array[Hash[Symbol, untyped]]
|
|
82
|
+
# Steep checks the body against both overloads at once, as one whose second
|
|
83
|
+
# parameter is optional, which neither overload's is.
|
|
84
|
+
def self.query(row, *arguments) # steep:ignore DifferentMethodParameterKind
|
|
85
|
+
database = ORM::Connection::SESSION.database
|
|
86
|
+
case row
|
|
87
|
+
when String then database.hashes(row, arguments)
|
|
88
|
+
when Class then database.rows(row, arguments.fetch(0), arguments.drop(1))
|
|
89
|
+
else raise ArgumentError, "Skyward.query takes a row class or the SQL as its first argument"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @rbs directory: String
|
|
94
|
+
# @rbs return: Array[String]
|
|
95
|
+
def self.migrate(directory)
|
|
96
|
+
database = ORM::Connection::SESSION.database
|
|
97
|
+
migrated = database.migrate(ORM::Migrations::Runner.read(directory))
|
|
98
|
+
case migrated
|
|
99
|
+
when Array
|
|
100
|
+
database.check(ORM::Tables::Loaded.table_classes(ORM::Record))
|
|
101
|
+
migrated
|
|
102
|
+
else raise ORM::MigrationError, ORM::Migrations::Runner.message(migrated)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# @rbs expression: String
|
|
107
|
+
# @rbs return: ORM::Tables::SQL
|
|
108
|
+
def self.sql(expression)
|
|
109
|
+
# Steep knows expression is a String, but untyped code can pass anything.
|
|
110
|
+
unless expression.is_a?(String) # steep:ignore UnreachableBranch
|
|
111
|
+
raise ArgumentError, "Skyward.sql takes the SQL as a String, not #{expression.inspect}"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
ORM::Tables::SQL.new(expression: expression.dup.freeze)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/adapters/postgresql/connection.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# PG::Connection runs SQL with exec_params, which returns a PG::Result, so this
|
|
4
|
+
# gives it the execute every adapter's connection has.
|
|
5
|
+
class Skyward::ORM::Adapters::PostgreSQL::Connection
|
|
6
|
+
@connection: PG::Connection
|
|
7
|
+
|
|
8
|
+
@changes: Integer
|
|
9
|
+
|
|
10
|
+
# @rbs connection: PG::Connection
|
|
11
|
+
# @rbs return: void
|
|
12
|
+
def initialize: (PG::Connection connection) -> void
|
|
13
|
+
|
|
14
|
+
# The block form clears each result as soon as its rows are read, so the
|
|
15
|
+
# rows it changed are kept for changes, as SQLite keeps them for its own.
|
|
16
|
+
# @rbs sql: String
|
|
17
|
+
# @rbs binds: Array[untyped]
|
|
18
|
+
# @rbs return: Array[Array[String?]]
|
|
19
|
+
def execute: (String sql, ?Array[untyped] binds) -> Array[Array[String?]]
|
|
20
|
+
|
|
21
|
+
# @dynamic changes
|
|
22
|
+
attr_reader changes: Integer
|
|
23
|
+
|
|
24
|
+
# @rbs sql: String
|
|
25
|
+
# @rbs *binds: untyped
|
|
26
|
+
# @rbs return: Array[Array[String?]]
|
|
27
|
+
def execute2: (String sql, *untyped binds) -> Array[Array[String?]]
|
|
28
|
+
|
|
29
|
+
# exec, unlike exec_params, runs every statement in the SQL.
|
|
30
|
+
# @rbs sql: String
|
|
31
|
+
# @rbs return: void
|
|
32
|
+
def execute_batch: (String sql) -> void
|
|
33
|
+
|
|
34
|
+
# Anything but idle counts, so a connection left mid-command or broken isn't
|
|
35
|
+
# reused either.
|
|
36
|
+
# @rbs return: bool
|
|
37
|
+
def transaction_active?: () -> bool
|
|
38
|
+
|
|
39
|
+
# @rbs return: void
|
|
40
|
+
def close: () -> void
|
|
41
|
+
end
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/adapters/postgresql.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Skyward::ORM::Adapters::PostgreSQL
|
|
4
|
+
SQL_TYPES: Hash[Skyward::ORM::Tables::column_type, String]
|
|
5
|
+
|
|
6
|
+
# As the catalog spells each type, which compatible? is given.
|
|
7
|
+
COMPATIBLE: Hash[Skyward::ORM::Tables::column_type, Array[String]]
|
|
8
|
+
|
|
9
|
+
# COMPATIBLE read backwards, taking the narrowest type for each.
|
|
10
|
+
COLUMN_TYPES: Hash[String, Skyward::ORM::Tables::column_type]
|
|
11
|
+
|
|
12
|
+
# The catalog puts a length or precision in parentheses.
|
|
13
|
+
MODIFIER: Regexp
|
|
14
|
+
|
|
15
|
+
# UTC, so a timestamp column, which has no zone, holds the same instant as a
|
|
16
|
+
# timestamptz, and to the microsecond, as PostgreSQL keeps it. Its trailing
|
|
17
|
+
# zeros go, as PostgreSQL writes a time back, so a default compares as text.
|
|
18
|
+
TIME_FORMAT: String
|
|
19
|
+
|
|
20
|
+
TRAILING_ZEROS: Regexp
|
|
21
|
+
|
|
22
|
+
# PostgreSQL reads a literal default back cast to its type, as 'normal'::text
|
|
23
|
+
# or '{}'::text[], and quotes a number that isn't a plain integer or decimal,
|
|
24
|
+
# as '-1'::integer.
|
|
25
|
+
CAST: Regexp
|
|
26
|
+
|
|
27
|
+
NUMERIC: Regexp
|
|
28
|
+
|
|
29
|
+
# Float() refuses the special values PostgreSQL writes out.
|
|
30
|
+
SPECIAL_FLOATS: Hash[String, Float]
|
|
31
|
+
|
|
32
|
+
MIGRATION_LOCK: Integer
|
|
33
|
+
|
|
34
|
+
# Each value comes back as text, and a boolean as t or f.
|
|
35
|
+
TRUE_TEXT: String
|
|
36
|
+
|
|
37
|
+
FALSE_TEXT: String
|
|
38
|
+
|
|
39
|
+
VIOLATIONS: Hash[String, Skyward::ORM::violation_kind]
|
|
40
|
+
|
|
41
|
+
CONSTRAINT_KINDS: Hash[String, Skyward::ORM::Catalog::constraint_kind]
|
|
42
|
+
|
|
43
|
+
# The tables an unqualified name finds, as every query names them.
|
|
44
|
+
TABLES: String
|
|
45
|
+
|
|
46
|
+
# pg_attrdef holds a generated column's expression as if it were its default.
|
|
47
|
+
COLUMNS: String
|
|
48
|
+
|
|
49
|
+
# Leaves out the indexes primary keys and unique constraints make, as SQLite's does.
|
|
50
|
+
INDEXES: String
|
|
51
|
+
|
|
52
|
+
# A check on no column has no conkey, so the join keeps it with no columns.
|
|
53
|
+
CONSTRAINTS: String
|
|
54
|
+
|
|
55
|
+
# @rbs return: String
|
|
56
|
+
def driver: () -> String
|
|
57
|
+
|
|
58
|
+
# @rbs return: Symbol
|
|
59
|
+
def adapter_name: () -> Symbol
|
|
60
|
+
|
|
61
|
+
# Values are decoded from PostgreSQL's ISO text, whatever the server's
|
|
62
|
+
# defaults, and times read and written in UTC. libpq prints each notice the
|
|
63
|
+
# server sends, so only warnings and worse are sent, or `skyward migrate`
|
|
64
|
+
# would print that schema_migrations already exists.
|
|
65
|
+
# @rbs location: String
|
|
66
|
+
# @rbs return: Skyward::ORM::_Connection
|
|
67
|
+
def connect: (String location) -> Skyward::ORM::_Connection
|
|
68
|
+
|
|
69
|
+
# @rbs (String _location, Integer size) -> Integer
|
|
70
|
+
def pool_size: (String _location, Integer size) -> Integer
|
|
71
|
+
|
|
72
|
+
# @rbs position: Integer
|
|
73
|
+
# @rbs return: String
|
|
74
|
+
def placeholder: (Integer position) -> String
|
|
75
|
+
|
|
76
|
+
# The protocol counts a statement's parameters in 16 bits.
|
|
77
|
+
# @rbs return: Integer
|
|
78
|
+
def bind_limit: () -> Integer
|
|
79
|
+
|
|
80
|
+
# PostgreSQL takes an OFFSET with no LIMIT before it.
|
|
81
|
+
# @rbs return: String?
|
|
82
|
+
def unlimited: () -> String?
|
|
83
|
+
|
|
84
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
85
|
+
# @rbs return: String?
|
|
86
|
+
def sql_type: (Skyward::ORM::Tables::Column column) -> String?
|
|
87
|
+
|
|
88
|
+
# @rbs return: String?
|
|
89
|
+
def identity: () -> String?
|
|
90
|
+
|
|
91
|
+
# @rbs return: bool
|
|
92
|
+
def alters_in_place?: () -> bool
|
|
93
|
+
|
|
94
|
+
# A second migrator waits at the lock until the first commits, and then sees
|
|
95
|
+
# what it ran. Any fixed key will do: the lock is the database's own.
|
|
96
|
+
# @rbs return: String
|
|
97
|
+
def begin_migration: () -> String
|
|
98
|
+
|
|
99
|
+
# PostgreSQL checks each foreign key as the migration writes.
|
|
100
|
+
# @rbs (Skyward::ORM::_Connection _connection) -> Array[String]
|
|
101
|
+
def foreign_key_violations: (Skyward::ORM::_Connection _connection) -> Array[String]
|
|
102
|
+
|
|
103
|
+
# Ending the transaction released the lock, and nothing else was set.
|
|
104
|
+
# @rbs return: String?
|
|
105
|
+
def end_migration: () -> String?
|
|
106
|
+
|
|
107
|
+
# @rbs expression: String
|
|
108
|
+
# @rbs return: String
|
|
109
|
+
def default_expression: (String expression) -> String
|
|
110
|
+
|
|
111
|
+
# @rbs default: String
|
|
112
|
+
# @rbs return: String
|
|
113
|
+
def catalog_default: (String default) -> String
|
|
114
|
+
|
|
115
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
116
|
+
# @rbs sql_type: String
|
|
117
|
+
# @rbs return: bool
|
|
118
|
+
def compatible?: (Skyward::ORM::Tables::Column column, String sql_type) -> bool
|
|
119
|
+
|
|
120
|
+
# PostgreSQL compares numeric as it is.
|
|
121
|
+
# @rbs (Skyward::ORM::Tables::column_type _type, String column) -> String
|
|
122
|
+
def comparable: (Skyward::ORM::Tables::column_type _type, String column) -> String
|
|
123
|
+
|
|
124
|
+
# @rbs sql_type: String
|
|
125
|
+
# @rbs return: Skyward::ORM::Tables::column_type?
|
|
126
|
+
def column_type: (String sql_type) -> Skyward::ORM::Tables::column_type?
|
|
127
|
+
|
|
128
|
+
# The driver sends every other value as its to_s, which PostgreSQL reads.
|
|
129
|
+
# @rbs value: untyped
|
|
130
|
+
# @rbs return: untyped
|
|
131
|
+
def encode: (untyped value) -> untyped
|
|
132
|
+
|
|
133
|
+
# The encoder quotes each item that needs it, the string NULL included. A
|
|
134
|
+
# boolean is written as PostgreSQL writes one back, so a default reads back
|
|
135
|
+
# as it was written.
|
|
136
|
+
# @rbs items: Array[untyped]
|
|
137
|
+
# @rbs return: String
|
|
138
|
+
def encode_array: (Array[untyped] items) -> String
|
|
139
|
+
|
|
140
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
141
|
+
# @rbs value: untyped
|
|
142
|
+
# @rbs return: untyped
|
|
143
|
+
def decode: (Skyward::ORM::Tables::Column column, untyped value) -> untyped
|
|
144
|
+
|
|
145
|
+
# @rbs (Skyward::ORM::_Connection connection) -> Array[Skyward::ORM::Catalog::Table]
|
|
146
|
+
def tables: (Skyward::ORM::_Connection connection) -> Array[Skyward::ORM::Catalog::Table]
|
|
147
|
+
|
|
148
|
+
# @rbs (StandardError error, Array[Skyward::ORM::Catalog::Table] tables, Symbol? _table)
|
|
149
|
+
# -> Skyward::ORM::Violation?
|
|
150
|
+
def violation: (StandardError error, Array[Skyward::ORM::Catalog::Table] tables, Symbol? _table) -> Skyward::ORM::Violation?
|
|
151
|
+
|
|
152
|
+
private
|
|
153
|
+
|
|
154
|
+
# @rbs type: Skyward::ORM::Tables::column_type
|
|
155
|
+
# @rbs sql_type: String
|
|
156
|
+
# @rbs return: bool
|
|
157
|
+
def accepts?: (Skyward::ORM::Tables::column_type type, String sql_type) -> bool
|
|
158
|
+
|
|
159
|
+
# @rbs type: Skyward::ORM::Tables::column_type
|
|
160
|
+
# @rbs value: untyped
|
|
161
|
+
# @rbs return: untyped
|
|
162
|
+
def scalar: (Skyward::ORM::Tables::column_type type, untyped value) -> untyped
|
|
163
|
+
|
|
164
|
+
# @rbs rows: Array[Array[untyped]]
|
|
165
|
+
# @rbs return: Array[Skyward::ORM::Catalog::Index]
|
|
166
|
+
def indexes: (Array[Array[untyped]] rows) -> Array[Skyward::ORM::Catalog::Index]
|
|
167
|
+
|
|
168
|
+
# @rbs rows: Array[Array[untyped]]
|
|
169
|
+
# @rbs return: Array[Skyward::ORM::Catalog::Constraint]
|
|
170
|
+
def constraints: (Array[Array[untyped]] rows) -> Array[Skyward::ORM::Catalog::Constraint]
|
|
171
|
+
|
|
172
|
+
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
173
|
+
# @rbs table: String?
|
|
174
|
+
# @rbs name: String?
|
|
175
|
+
# @rbs return: Array[Symbol]
|
|
176
|
+
def constrained: (Array[Skyward::ORM::Catalog::Table] tables, String? table, String? name) -> Array[Symbol]
|
|
177
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/adapters/sqlite/constraints.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# SQLite keeps no catalog of constraints, only each table's CREATE TABLE
|
|
4
|
+
# statement, so their names, kinds, columns and definitions are read from that.
|
|
5
|
+
module Skyward::ORM::Adapters::SQLite::Constraints
|
|
6
|
+
type token = [ Symbol, String, Integer, Integer ]
|
|
7
|
+
|
|
8
|
+
TOKEN: Regexp
|
|
9
|
+
|
|
10
|
+
DEPTH: Hash[Symbol, Integer]
|
|
11
|
+
|
|
12
|
+
NAMES: Array[Symbol]
|
|
13
|
+
|
|
14
|
+
TABLE_CONSTRAINTS: Array[String]
|
|
15
|
+
|
|
16
|
+
KINDS: Hash[String, Skyward::ORM::Catalog::constraint_kind]
|
|
17
|
+
|
|
18
|
+
# The words that start a column's next constraint, or its default or collation.
|
|
19
|
+
COLUMN_CLAUSES: Array[String]
|
|
20
|
+
|
|
21
|
+
# A reference's ON DELETE SET NULL and SET DEFAULT end in these.
|
|
22
|
+
SET_TO: Array[String]
|
|
23
|
+
|
|
24
|
+
# @rbs sql: String
|
|
25
|
+
# @rbs columns: Array[Symbol]
|
|
26
|
+
# @rbs return: Array[Skyward::ORM::Catalog::Constraint]
|
|
27
|
+
def read: (String sql, Array[Symbol] columns) -> Array[Skyward::ORM::Catalog::Constraint]
|
|
28
|
+
|
|
29
|
+
# SQLite's grammar makes GENERATED ALWAYS AS a column constraint, and
|
|
30
|
+
# table_xinfo doesn't give its expression, so that's read from here too.
|
|
31
|
+
# @rbs sql: String
|
|
32
|
+
# @rbs return: Hash[Symbol, String]
|
|
33
|
+
def generated: (String sql) -> Hash[Symbol, String]
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# The scan covers every character, since its last alternative matches any
|
|
38
|
+
# one, so each token starts where the one before it ends.
|
|
39
|
+
# @rbs sql: String
|
|
40
|
+
# @rbs return: Array[Array[[token, Integer]]]
|
|
41
|
+
def definitions: (String sql) -> Array[Array[[ token, Integer ]]]
|
|
42
|
+
|
|
43
|
+
# @rbs text: String
|
|
44
|
+
# @rbs start: Integer
|
|
45
|
+
# @rbs return: token?
|
|
46
|
+
def token: (String text, Integer start) -> token?
|
|
47
|
+
|
|
48
|
+
# A column's own constraints are on that column. A table constraint names
|
|
49
|
+
# its columns in parentheses, and a check is on the columns its expression
|
|
50
|
+
# mentions.
|
|
51
|
+
# @rbs sql: String
|
|
52
|
+
# @rbs definition: Array[[token, Integer]]
|
|
53
|
+
# @rbs columns: Array[Symbol]
|
|
54
|
+
# @rbs return: Array[Skyward::ORM::Catalog::Constraint]
|
|
55
|
+
def constraints: (String sql, Array[[ token, Integer ]] definition, Array[Symbol] columns) -> Array[Skyward::ORM::Catalog::Constraint]
|
|
56
|
+
|
|
57
|
+
# A column's constraint, written as the table constraint it's the same as.
|
|
58
|
+
# @rbs sql: String
|
|
59
|
+
# @rbs kind: Skyward::ORM::Catalog::constraint_kind
|
|
60
|
+
# @rbs column: Symbol
|
|
61
|
+
# @rbs rest: Array[[token, Integer]]
|
|
62
|
+
# @rbs return: String
|
|
63
|
+
def on_column: (String sql, Skyward::ORM::Catalog::constraint_kind kind, Symbol column, Array[[ token, Integer ]] rest) -> String
|
|
64
|
+
|
|
65
|
+
# A column constraint runs until the column's next clause. ON DELETE SET
|
|
66
|
+
# NULL and NOT DEFERRABLE are inside a reference, though, not clauses of
|
|
67
|
+
# their own.
|
|
68
|
+
# @rbs rest: Array[[token, Integer]]
|
|
69
|
+
# @rbs return: Array[token]
|
|
70
|
+
def own: (Array[[ token, Integer ]] rest) -> Array[token]
|
|
71
|
+
|
|
72
|
+
# @rbs sql: String
|
|
73
|
+
# @rbs tokens: Array[token]
|
|
74
|
+
# @rbs return: String
|
|
75
|
+
def text: (String sql, Array[token] tokens) -> String
|
|
76
|
+
|
|
77
|
+
# @rbs token: token
|
|
78
|
+
# @rbs return: String?
|
|
79
|
+
def word: (token token) -> String?
|
|
80
|
+
|
|
81
|
+
# @rbs rest: Array[[token, Integer]]
|
|
82
|
+
# @rbs return: Array[token]
|
|
83
|
+
def first_parenthesized: (Array[[ token, Integer ]] rest) -> Array[token]
|
|
84
|
+
|
|
85
|
+
# @rbs tokens: Array[token]
|
|
86
|
+
# @rbs columns: Array[Symbol]
|
|
87
|
+
# @rbs return: Array[Symbol]
|
|
88
|
+
def mentioned: (Array[token] tokens, Array[Symbol] columns) -> Array[Symbol]
|
|
89
|
+
|
|
90
|
+
# @rbs tokens: Array[token]
|
|
91
|
+
# @rbs return: Symbol
|
|
92
|
+
def referenced: (Array[token] tokens) -> Symbol
|
|
93
|
+
end
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Generated from lib/skyward/orm/adapters/sqlite.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Skyward::ORM::Adapters::SQLite
|
|
4
|
+
# The first SQLite with RETURNING, which every write into a row class uses.
|
|
5
|
+
MINIMUM_VERSION: Gem::Version
|
|
6
|
+
|
|
7
|
+
SQL_TYPES: Hash[Skyward::ORM::Tables::column_type, String]
|
|
8
|
+
|
|
9
|
+
# Fixed width and UTC, so text order is time order, and to the microsecond,
|
|
10
|
+
# as PostgreSQL keeps it. It's the format of SQLite's own CURRENT_TIMESTAMP,
|
|
11
|
+
# with the fraction added, so the two compare.
|
|
12
|
+
TIME_FORMAT: String
|
|
13
|
+
|
|
14
|
+
# SQLite's extended result codes: SQLITE_CONSTRAINT_CHECK, _FOREIGNKEY,
|
|
15
|
+
# _NOTNULL, _PRIMARYKEY and _UNIQUE.
|
|
16
|
+
VIOLATIONS: Hash[Integer, Skyward::ORM::violation_kind]
|
|
17
|
+
|
|
18
|
+
# SQLite enforces a RESTRICT foreign key as a trigger would, so it reports
|
|
19
|
+
# SQLITE_CONSTRAINT_TRIGGER, and only the message tells it from a trigger's RAISE.
|
|
20
|
+
TRIGGER: Integer
|
|
21
|
+
|
|
22
|
+
RESTRICTED: String
|
|
23
|
+
|
|
24
|
+
# Types whose values keep their meaning under NUMERIC affinity, which Rails
|
|
25
|
+
# gives BOOLEAN, DATE and DATETIME. A boolean is already a number, and a date
|
|
26
|
+
# or time is never a well-formed number, so none is converted. A String or a
|
|
27
|
+
# BigDecimal would be: NUMERIC turns "1.10" into 1.1.
|
|
28
|
+
NUMERIC_SAFE: Array[Skyward::ORM::Tables::column_type]
|
|
29
|
+
|
|
30
|
+
# The names Rails writes for the NUMERIC_SAFE types, with any precision, as
|
|
31
|
+
# in DATETIME(6). Nothing else in the catalog tells a bool, Date or Time from
|
|
32
|
+
# an Integer or String, since a migration stores them as INTEGER and TEXT.
|
|
33
|
+
NUMERIC_NAMES: Hash[String, Skyward::ORM::Tables::column_type]
|
|
34
|
+
|
|
35
|
+
PRECISION: Regexp
|
|
36
|
+
|
|
37
|
+
AFFINITY_TYPES: Hash[Symbol, Skyward::ORM::Tables::column_type]
|
|
38
|
+
|
|
39
|
+
UNIQUE_KINDS: Array[Skyward::ORM::Catalog::constraint_kind]
|
|
40
|
+
|
|
41
|
+
BUSY_TIMEOUT_MS: Integer
|
|
42
|
+
|
|
43
|
+
# table_info leaves out generated columns, which table_xinfo marks hidden 2
|
|
44
|
+
# (virtual) or 3 (stored). Hidden 1 is a virtual table's own hidden column.
|
|
45
|
+
COLUMNS: String
|
|
46
|
+
|
|
47
|
+
INDEXES: String
|
|
48
|
+
|
|
49
|
+
# What SQLite takes as a default without parentheses: a string, blob or
|
|
50
|
+
# number, NULL, TRUE or FALSE.
|
|
51
|
+
LITERAL: Regexp
|
|
52
|
+
|
|
53
|
+
# @rbs return: String
|
|
54
|
+
def driver: () -> String
|
|
55
|
+
|
|
56
|
+
# @rbs return: Symbol
|
|
57
|
+
def adapter_name: () -> Symbol
|
|
58
|
+
|
|
59
|
+
# @rbs location: String
|
|
60
|
+
# @rbs return: Skyward::ORM::_Connection
|
|
61
|
+
def connect: (String location) -> Skyward::ORM::_Connection
|
|
62
|
+
|
|
63
|
+
# Each connection to :memory: opens its own empty database, so there can be
|
|
64
|
+
# only the one.
|
|
65
|
+
# @rbs location: String
|
|
66
|
+
# @rbs size: Integer
|
|
67
|
+
# @rbs return: Integer
|
|
68
|
+
def pool_size: (String location, Integer size) -> Integer
|
|
69
|
+
|
|
70
|
+
# @rbs version: String
|
|
71
|
+
# @rbs return: void
|
|
72
|
+
def require_version: (String version) -> void
|
|
73
|
+
|
|
74
|
+
# @rbs (Integer _position) -> String
|
|
75
|
+
def placeholder: (Integer _position) -> String
|
|
76
|
+
|
|
77
|
+
# SQLITE_MAX_VARIABLE_NUMBER's default since 3.32. A SQLite built with a
|
|
78
|
+
# lower one refuses with its own error, since the sqlite3 gem doesn't expose
|
|
79
|
+
# sqlite3_limit to read it.
|
|
80
|
+
# @rbs return: Integer
|
|
81
|
+
def bind_limit: () -> Integer
|
|
82
|
+
|
|
83
|
+
# SQLite takes an OFFSET only after a LIMIT, and a negative one is no limit.
|
|
84
|
+
# @rbs return: String
|
|
85
|
+
def unlimited: () -> String
|
|
86
|
+
|
|
87
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
88
|
+
# @rbs return: String?
|
|
89
|
+
def sql_type: (Skyward::ORM::Tables::Column column) -> String?
|
|
90
|
+
|
|
91
|
+
# An INTEGER PRIMARY KEY is SQLite's rowid, which numbers rows on its own.
|
|
92
|
+
# @rbs return: String?
|
|
93
|
+
def identity: () -> String?
|
|
94
|
+
|
|
95
|
+
# SQLite's ALTER TABLE can't change a column or a constraint, so a migration
|
|
96
|
+
# rebuilds the table instead.
|
|
97
|
+
# @rbs return: bool
|
|
98
|
+
def alters_in_place?: () -> bool
|
|
99
|
+
|
|
100
|
+
# SQLite takes only a literal as a default, unless the expression is in parentheses.
|
|
101
|
+
# @rbs expression: String
|
|
102
|
+
# @rbs return: String
|
|
103
|
+
def default_expression: (String expression) -> String
|
|
104
|
+
|
|
105
|
+
# The catalog puts back the parentheses SQLite drops, so it reads a default
|
|
106
|
+
# back as it was written.
|
|
107
|
+
# @rbs default: String
|
|
108
|
+
# @rbs return: String
|
|
109
|
+
def catalog_default: (String default) -> String
|
|
110
|
+
|
|
111
|
+
# SQLite stores a value by its column's affinity, which it reads from the
|
|
112
|
+
# declared type, so any declared type with the same affinity is compatible,
|
|
113
|
+
# and for NUMERIC_SAFE types, NUMERIC as well.
|
|
114
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
115
|
+
# @rbs sql_type: String
|
|
116
|
+
# @rbs return: bool
|
|
117
|
+
def compatible?: (Skyward::ORM::Tables::Column column, String sql_type) -> bool
|
|
118
|
+
|
|
119
|
+
# A decimal's text orders "10.5" before "9.0", so a range or an order
|
|
120
|
+
# compares it as a REAL, which is exact to 15 significant digits.
|
|
121
|
+
# @rbs type: Skyward::ORM::Tables::column_type
|
|
122
|
+
# @rbs column: String
|
|
123
|
+
# @rbs return: String
|
|
124
|
+
def comparable: (Skyward::ORM::Tables::column_type type, String column) -> String
|
|
125
|
+
|
|
126
|
+
# @rbs sql_type: String
|
|
127
|
+
# @rbs return: Skyward::ORM::Tables::column_type?
|
|
128
|
+
def column_type: (String sql_type) -> Skyward::ORM::Tables::column_type?
|
|
129
|
+
|
|
130
|
+
# @rbs value: untyped
|
|
131
|
+
# @rbs return: untyped
|
|
132
|
+
def encode: (untyped value) -> untyped
|
|
133
|
+
|
|
134
|
+
# JSON holds a boolean as one, where a column holds it as 0 or 1.
|
|
135
|
+
# @rbs items: Array[untyped]
|
|
136
|
+
# @rbs return: String
|
|
137
|
+
def encode_array: (Array[untyped] items) -> String
|
|
138
|
+
|
|
139
|
+
# @rbs column: Skyward::ORM::Tables::Column
|
|
140
|
+
# @rbs value: untyped
|
|
141
|
+
# @rbs return: untyped
|
|
142
|
+
def decode: (Skyward::ORM::Tables::Column column, untyped value) -> untyped
|
|
143
|
+
|
|
144
|
+
# @rbs (Skyward::ORM::_Connection connection) -> Array[Skyward::ORM::Catalog::Table]
|
|
145
|
+
def tables: (Skyward::ORM::_Connection connection) -> Array[Skyward::ORM::Catalog::Table]
|
|
146
|
+
|
|
147
|
+
# Foreign keys go off first, as SQLite's procedure for changing a table says,
|
|
148
|
+
# so dropping a table the migration rebuilds doesn't cascade to the rows that
|
|
149
|
+
# refer to it, and inside a transaction the PRAGMA does nothing. BEGIN
|
|
150
|
+
# IMMEDIATE takes the write lock as the transaction begins rather than at its
|
|
151
|
+
# first write, so a second migrator waits there, and then sees what the first ran.
|
|
152
|
+
# @rbs return: String
|
|
153
|
+
def begin_migration: () -> String
|
|
154
|
+
|
|
155
|
+
# @rbs (Skyward::ORM::_Connection connection) -> Array[String]
|
|
156
|
+
def foreign_key_violations: (Skyward::ORM::_Connection connection) -> Array[String]
|
|
157
|
+
|
|
158
|
+
# @rbs return: String
|
|
159
|
+
def end_migration: () -> String
|
|
160
|
+
|
|
161
|
+
# The code says which kind of constraint failed. The message names the
|
|
162
|
+
# columns of a unique or not-null one, and the name of a check, and the rest
|
|
163
|
+
# comes from the schema, from the table written, or from every table when
|
|
164
|
+
# raw SQL doesn't say which it writes.
|
|
165
|
+
# @rbs error: StandardError
|
|
166
|
+
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
167
|
+
# @rbs table: Symbol?
|
|
168
|
+
# @rbs return: Skyward::ORM::Violation?
|
|
169
|
+
def violation: (StandardError error, Array[Skyward::ORM::Catalog::Table] tables, Symbol? table) -> Skyward::ORM::Violation?
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
|
|
173
|
+
# @rbs type: Skyward::ORM::Tables::column_type
|
|
174
|
+
# @rbs value: untyped
|
|
175
|
+
# @rbs return: untyped
|
|
176
|
+
def scalar: (Skyward::ORM::Tables::column_type type, untyped value) -> untyped
|
|
177
|
+
|
|
178
|
+
# An Array[Float]'s JSON may hold an Integer, as an Array[Float] takes one.
|
|
179
|
+
# @rbs type: Skyward::ORM::Tables::column_type
|
|
180
|
+
# @rbs value: untyped
|
|
181
|
+
# @rbs return: untyped
|
|
182
|
+
def item: (Skyward::ORM::Tables::column_type type, untyped value) -> untyped
|
|
183
|
+
|
|
184
|
+
# @rbs sql_type: String
|
|
185
|
+
# @rbs return: Symbol
|
|
186
|
+
def affinity: (String sql_type) -> Symbol
|
|
187
|
+
|
|
188
|
+
# @rbs rows: Array[Array[untyped]]
|
|
189
|
+
# @rbs return: Array[Skyward::ORM::Catalog::Index]
|
|
190
|
+
def indexes: (Array[Array[untyped]] rows) -> Array[Skyward::ORM::Catalog::Index]
|
|
191
|
+
|
|
192
|
+
# SQLite reads a default back without the parentheses an expression was
|
|
193
|
+
# written in, so they go back on, as a migration writes them.
|
|
194
|
+
# @rbs default: String?
|
|
195
|
+
# @rbs return: String?
|
|
196
|
+
def default: (String? default) -> String?
|
|
197
|
+
|
|
198
|
+
# SQLite names a unique index on expressions rather than its columns.
|
|
199
|
+
# @rbs message: String
|
|
200
|
+
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
201
|
+
# @rbs return: Skyward::ORM::Violation
|
|
202
|
+
def unique: (String message, Array[Skyward::ORM::Catalog::Table] tables) -> Skyward::ORM::Violation
|
|
203
|
+
|
|
204
|
+
# @rbs message: String
|
|
205
|
+
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
206
|
+
# @rbs table: Symbol?
|
|
207
|
+
# @rbs return: Skyward::ORM::Violation
|
|
208
|
+
def check: (String message, Array[Skyward::ORM::Catalog::Table] tables, Symbol? table) -> Skyward::ORM::Violation
|
|
209
|
+
|
|
210
|
+
# SQLite's message names no key at all, so it's the one key the table has
|
|
211
|
+
# or that refers to it. With more than one, it can't say which.
|
|
212
|
+
# @rbs message: String
|
|
213
|
+
# @rbs tables: Array[Skyward::ORM::Catalog::Table]
|
|
214
|
+
# @rbs table: Symbol?
|
|
215
|
+
# @rbs return: Skyward::ORM::Violation
|
|
216
|
+
def foreign_key: (String message, Array[Skyward::ORM::Catalog::Table] tables, Symbol? table) -> Skyward::ORM::Violation
|
|
217
|
+
|
|
218
|
+
# SQLite names them as table.column: "UNIQUE constraint failed: todos.list_id, todos.title".
|
|
219
|
+
# @rbs message: String
|
|
220
|
+
# @rbs return: [Symbol, Array[Symbol]]
|
|
221
|
+
def failed_columns: (String message) -> [ Symbol, Array[Symbol] ]
|
|
222
|
+
|
|
223
|
+
# @rbs message: String
|
|
224
|
+
# @rbs return: String
|
|
225
|
+
def detail: (String message) -> String
|
|
226
|
+
end
|