torque-postgresql 4.1.0 → 4.1.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/Rakefile +28 -0
- data/lib/generators/torque/skill_generator.rb +17 -0
- data/lib/generators/torque/templates/trigger.sql.erb +3 -0
- data/lib/generators/torque/trigger_generator.rb +13 -0
- data/lib/torque/postgresql/adapter/database_statements.rb +9 -0
- data/lib/torque/postgresql/adapter/oid/array.rb +0 -4
- data/lib/torque/postgresql/adapter/oid/composite.rb +2 -1
- data/lib/torque/postgresql/adapter/oid/enum.rb +1 -1
- data/lib/torque/postgresql/adapter/oid/enum_set.rb +2 -2
- data/lib/torque/postgresql/adapter/oid/interval.rb +1 -1
- data/lib/torque/postgresql/adapter/oid/lquery.rb +45 -28
- data/lib/torque/postgresql/adapter/oid/ltree.rb +67 -9
- data/lib/torque/postgresql/adapter/oid/struct.rb +1 -1
- data/lib/torque/postgresql/adapter/oid.rb +13 -0
- data/lib/torque/postgresql/adapter/schema_definitions.rb +5 -0
- data/lib/torque/postgresql/adapter/schema_dumper.rb +1 -0
- data/lib/torque/postgresql/arel/nodes.rb +51 -0
- data/lib/torque/postgresql/arel/visitors.rb +46 -0
- data/lib/torque/postgresql/attributes/base.rb +10 -7
- data/lib/torque/postgresql/attributes/composite.rb +1 -5
- data/lib/torque/postgresql/attributes/enum.rb +1 -6
- data/lib/torque/postgresql/attributes/lquery.rb +67 -127
- data/lib/torque/postgresql/attributes/ltree.rb +35 -83
- data/lib/torque/postgresql/base.rb +9 -1
- data/lib/torque/postgresql/config.rb +21 -3
- data/lib/torque/postgresql/geometry_builder.rb +4 -10
- data/lib/torque/postgresql/inheritance.rb +5 -5
- data/lib/torque/postgresql/predicate_builder/arel_attribute_handler.rb +1 -1
- data/lib/torque/postgresql/predicate_builder/array_handler.rb +16 -8
- data/lib/torque/postgresql/predicate_builder/composite_handler.rb +18 -5
- data/lib/torque/postgresql/predicate_builder/ltree_handler.rb +86 -18
- data/lib/torque/postgresql/predicate_builder/struct_handler.rb +29 -9
- data/lib/torque/postgresql/predicate_builder.rb +38 -11
- data/lib/torque/postgresql/railtie.rb +17 -0
- data/lib/torque/postgresql/relation/auxiliary_statement.rb +7 -3
- data/lib/torque/postgresql/relation/buckets.rb +2 -1
- data/lib/torque/postgresql/relation/cross_join.rb +193 -0
- data/lib/torque/postgresql/relation/inheritance.rb +1 -2
- data/lib/torque/postgresql/relation/join_series.rb +1 -0
- data/lib/torque/postgresql/relation/merger.rb +9 -0
- data/lib/torque/postgresql/relation/segments.rb +140 -0
- data/lib/torque/postgresql/relation.rb +23 -4
- data/lib/torque/postgresql/version.rb +1 -1
- data/lib/torque/postgresql/versioned_commands/command_migration.rb +23 -0
- data/lib/torque/postgresql/versioned_commands.rb +39 -0
- data/lib/torque/postgresql.rb +0 -2
- data/sig/generators/torque/function_generator.rbs +9 -0
- data/sig/generators/torque/skill_generator.rbs +7 -0
- data/sig/generators/torque/trigger_generator.rbs +9 -0
- data/sig/generators/torque/type_generator.rbs +9 -0
- data/sig/generators/torque/view_generator.rbs +9 -0
- data/sig/manifest.yaml +7 -0
- data/sig/torque/postgresql/adapter/database_statements.rbs +42 -0
- data/sig/torque/postgresql/adapter/inheritance_statements.rbs +36 -0
- data/sig/torque/postgresql/adapter/oid/array.rbs +20 -0
- data/sig/torque/postgresql/adapter/oid/box.rbs +28 -0
- data/sig/torque/postgresql/adapter/oid/circle.rbs +33 -0
- data/sig/torque/postgresql/adapter/oid/composite.rbs +35 -0
- data/sig/torque/postgresql/adapter/oid/enum.rbs +28 -0
- data/sig/torque/postgresql/adapter/oid/enum_set.rbs +19 -0
- data/sig/torque/postgresql/adapter/oid/interval.rbs +20 -0
- data/sig/torque/postgresql/adapter/oid/line.rbs +33 -0
- data/sig/torque/postgresql/adapter/oid/lquery.rbs +21 -0
- data/sig/torque/postgresql/adapter/oid/ltree.rbs +32 -0
- data/sig/torque/postgresql/adapter/oid/range.rbs +28 -0
- data/sig/torque/postgresql/adapter/oid/segment.rbs +38 -0
- data/sig/torque/postgresql/adapter/oid/struct.rbs +41 -0
- data/sig/torque/postgresql/adapter/oid/struct_list.rbs +20 -0
- data/sig/torque/postgresql/adapter/oid/struct_set.rbs +18 -0
- data/sig/torque/postgresql/adapter/oid.rbs +9 -0
- data/sig/torque/postgresql/adapter/quoting.rbs +20 -0
- data/sig/torque/postgresql/adapter/schema_creation.rbs +13 -0
- data/sig/torque/postgresql/adapter/schema_definitions.rbs +55 -0
- data/sig/torque/postgresql/adapter/schema_dumper.rbs +37 -0
- data/sig/torque/postgresql/adapter/schema_overrides.rbs +46 -0
- data/sig/torque/postgresql/adapter/schema_statements.rbs +50 -0
- data/sig/torque/postgresql/adapter.rbs +24 -0
- data/sig/torque/postgresql/arel/infix_operation.rbs +79 -0
- data/sig/torque/postgresql/arel/join_source.rbs +19 -0
- data/sig/torque/postgresql/arel/nodes.rbs +83 -0
- data/sig/torque/postgresql/arel/operations.rbs +28 -0
- data/sig/torque/postgresql/arel/select_manager.rbs +15 -0
- data/sig/torque/postgresql/arel/visitors.rbs +30 -0
- data/sig/torque/postgresql/arel.rbs +6 -0
- data/sig/torque/postgresql/associations/association_scope.rbs +28 -0
- data/sig/torque/postgresql/associations/belongs_to_many_association.rbs +51 -0
- data/sig/torque/postgresql/associations/builder/belongs_to_many.rbs +24 -0
- data/sig/torque/postgresql/associations/builder/has_many.rbs +15 -0
- data/sig/torque/postgresql/associations/builder.rbs +8 -0
- data/sig/torque/postgresql/associations/foreign_association.rbs +16 -0
- data/sig/torque/postgresql/associations/join_dependency.rbs +16 -0
- data/sig/torque/postgresql/associations/preloader/association.rbs +32 -0
- data/sig/torque/postgresql/associations/preloader/loader_query.rbs +20 -0
- data/sig/torque/postgresql/associations/preloader.rbs +8 -0
- data/sig/torque/postgresql/associations.rbs +17 -0
- data/sig/torque/postgresql/attributes/base.rbs +37 -0
- data/sig/torque/postgresql/attributes/builder/enum.rbs +38 -0
- data/sig/torque/postgresql/attributes/builder/full_text_search.rbs +27 -0
- data/sig/torque/postgresql/attributes/builder/period.rbs +106 -0
- data/sig/torque/postgresql/attributes/builder.rbs +19 -0
- data/sig/torque/postgresql/attributes/composite.rbs +28 -0
- data/sig/torque/postgresql/attributes/enum.rbs +69 -0
- data/sig/torque/postgresql/attributes/enum_set.rbs +75 -0
- data/sig/torque/postgresql/attributes/full_text_search.rbs +13 -0
- data/sig/torque/postgresql/attributes/lazy.rbs +17 -0
- data/sig/torque/postgresql/attributes/lquery.rbs +48 -0
- data/sig/torque/postgresql/attributes/ltree.rbs +46 -0
- data/sig/torque/postgresql/attributes/period.rbs +13 -0
- data/sig/torque/postgresql/attributes/simple_enum.rbs +39 -0
- data/sig/torque/postgresql/attributes/struct.rbs +38 -0
- data/sig/torque/postgresql/attributes.rbs +6 -0
- data/sig/torque/postgresql/autosave_association.rbs +16 -0
- data/sig/torque/postgresql/auxiliary_statement/recursive.rbs +22 -0
- data/sig/torque/postgresql/auxiliary_statement/settings.rbs +63 -0
- data/sig/torque/postgresql/auxiliary_statement.rbs +57 -0
- data/sig/torque/postgresql/base.rbs +41 -0
- data/sig/torque/postgresql/collector.rbs +7 -0
- data/sig/torque/postgresql/config.rbs +9 -0
- data/sig/torque/postgresql/function.rbs +21 -0
- data/sig/torque/postgresql/geometry_builder.rbs +20 -0
- data/sig/torque/postgresql/i18n.rbs +15 -0
- data/sig/torque/postgresql/inheritance/expander.rbs +23 -0
- data/sig/torque/postgresql/inheritance/record.rbs +20 -0
- data/sig/torque/postgresql/inheritance.rbs +47 -0
- data/sig/torque/postgresql/insert_all.rbs +22 -0
- data/sig/torque/postgresql/migration/command_recorder.rbs +30 -0
- data/sig/torque/postgresql/migration.rbs +6 -0
- data/sig/torque/postgresql/predicate_builder/arel_attribute_handler.rbs +15 -0
- data/sig/torque/postgresql/predicate_builder/array_handler.rbs +26 -0
- data/sig/torque/postgresql/predicate_builder/composite_handler.rbs +26 -0
- data/sig/torque/postgresql/predicate_builder/enumerator_lazy_handler.rbs +18 -0
- data/sig/torque/postgresql/predicate_builder/ltree_handler.rbs +36 -0
- data/sig/torque/postgresql/predicate_builder/regexp_handler.rbs +16 -0
- data/sig/torque/postgresql/predicate_builder/struct_handler.rbs +24 -0
- data/sig/torque/postgresql/predicate_builder.rbs +23 -0
- data/sig/torque/postgresql/predicate_table.rbs +24 -0
- data/sig/torque/postgresql/railtie.rbs +10 -0
- data/sig/torque/postgresql/reflection/abstract_reflection.rbs +22 -0
- data/sig/torque/postgresql/reflection/association_reflection.rbs +18 -0
- data/sig/torque/postgresql/reflection/belongs_to_many_reflection.rbs +30 -0
- data/sig/torque/postgresql/reflection/has_many_reflection.rbs +14 -0
- data/sig/torque/postgresql/reflection/runtime_reflection.rbs +18 -0
- data/sig/torque/postgresql/reflection/through_reflection.rbs +14 -0
- data/sig/torque/postgresql/reflection.rbs +11 -0
- data/sig/torque/postgresql/relation/auxiliary_statement.rbs +29 -0
- data/sig/torque/postgresql/relation/buckets.rbs +35 -0
- data/sig/torque/postgresql/relation/cross_join.rbs +63 -0
- data/sig/torque/postgresql/relation/distinct_on.rbs +16 -0
- data/sig/torque/postgresql/relation/inheritance.rbs +48 -0
- data/sig/torque/postgresql/relation/join_series.rbs +28 -0
- data/sig/torque/postgresql/relation/merger.rbs +23 -0
- data/sig/torque/postgresql/relation/segments.rbs +27 -0
- data/sig/torque/postgresql/relation.rbs +48 -0
- data/sig/torque/postgresql/schema_cache/bound_schema_reflection.rbs +14 -0
- data/sig/torque/postgresql/schema_cache/inheritance.rbs +12 -0
- data/sig/torque/postgresql/schema_cache/schema_reflection.rbs +14 -0
- data/sig/torque/postgresql/schema_cache.rbs +43 -0
- data/sig/torque/postgresql/table_name.rbs +20 -0
- data/sig/torque/postgresql/validations.rbs +13 -0
- data/sig/torque/postgresql/version.rbs +5 -0
- data/sig/torque/postgresql/versioned_commands/command_migration.rbs +54 -0
- data/sig/torque/postgresql/versioned_commands/generator.rbs +17 -0
- data/sig/torque/postgresql/versioned_commands/migration_context.rbs +30 -0
- data/sig/torque/postgresql/versioned_commands/migrator.rbs +19 -0
- data/sig/torque/postgresql/versioned_commands/schema_table.rbs +23 -0
- data/sig/torque/postgresql/versioned_commands.rbs +25 -0
- data/sig/torque/postgresql.rbs +26 -0
- data/skills/torque-postgresql/SKILL.md +70 -0
- data/spec/fixtures/migrations/20250101000008_create_trigger_audit_users_v1.sql +3 -0
- data/spec/initialize.rb +9 -0
- data/spec/mocks/cache_query.rb +1 -1
- data/spec/rbs_helper.rb +8 -0
- data/spec/schema.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/tests/arel_spec.rb +1 -3
- data/spec/tests/auxiliary_statement_spec.rb +12 -0
- data/spec/tests/buckets_spec.rb +122 -0
- data/spec/tests/composite_spec.rb +67 -0
- data/spec/tests/cross_join_spec.rb +185 -0
- data/spec/tests/distinct_on_spec.rb +5 -0
- data/spec/tests/enum_set_spec.rb +4 -0
- data/spec/tests/enum_spec.rb +20 -4
- data/spec/tests/geometric_builder_spec.rb +16 -5
- data/spec/tests/has_many_spec.rb +2 -1
- data/spec/tests/interval_spec.rb +6 -0
- data/spec/tests/ltree_spec.rb +398 -64
- data/spec/tests/predicate_builder_spec.rb +120 -0
- data/spec/tests/relation_spec.rb +25 -69
- data/spec/tests/segments_spec.rb +264 -0
- data/spec/tests/struct_spec.rb +202 -0
- data/spec/tests/table_inheritance_spec.rb +10 -0
- data/spec/tests/versioned_commands_spec.rb +145 -0
- metadata +153 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Arel
|
|
4
|
+
module Operations
|
|
5
|
+
def pg_cast: (column_ref type, ?bool | Symbol array) -> Nodes::Cast
|
|
6
|
+
def cast: (column_ref type, ?bool | Symbol array) -> untyped
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module Arel
|
|
13
|
+
module Attributes
|
|
14
|
+
class Attribute
|
|
15
|
+
include Torque::PostgreSQL::Arel::Operations
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Nodes
|
|
20
|
+
class SqlLiteral
|
|
21
|
+
include Torque::PostgreSQL::Arel::Operations
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Node
|
|
25
|
+
include Torque::PostgreSQL::Arel::Operations
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Arel
|
|
4
|
+
module Visitors
|
|
5
|
+
def visit_Arel_Nodes_JoinSource: (::Arel::Nodes::JoinSource o, collector collector) -> collector
|
|
6
|
+
def visit_Arel_Nodes_Quoted: (::Arel::Nodes::Quoted o, collector collector) -> collector
|
|
7
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_Ref: (Nodes::Ref o, collector collector) -> collector
|
|
8
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_Column: (Nodes::Column o, collector collector) -> collector
|
|
9
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_Property: (Nodes::Property o, collector collector) -> collector
|
|
10
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_CrossJoin: (Nodes::CrossJoin o, collector collector) -> collector
|
|
11
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_FromItem: (Nodes::FromItem o, collector collector) -> collector
|
|
12
|
+
def visit_Torque_PostgreSQL_Arel_Nodes_Cast: (Nodes::Cast o, collector collector) -> collector
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def visit_definitions: (Hash[column_ref, String?] definitions, collector collector) -> collector
|
|
17
|
+
def visit_alias_columns: (Hash[column_ref, String?] columns, collector collector) -> collector
|
|
18
|
+
def quote_array: (Enumerable[untyped] value, collector collector) -> collector
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module Arel
|
|
25
|
+
module Visitors
|
|
26
|
+
class PostgreSQL
|
|
27
|
+
prepend Torque::PostgreSQL::Arel::Visitors
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module AssociationScope
|
|
5
|
+
class PredicateBuilderArray
|
|
6
|
+
include PredicateBuilder::ArrayHandler
|
|
7
|
+
|
|
8
|
+
def call_with_empty: (arel_node attribute) -> String
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def get_bind_values: (*untyped) -> Array[untyped]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def last_chain_scope: (relation scope, any_reflection reflection, record owner) -> relation
|
|
18
|
+
def next_chain_scope: (relation scope, any_reflection reflection, any_reflection next_reflection) -> relation
|
|
19
|
+
def transform_value: (untyped value) -> untyped
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class ActiveRecord::Associations::AssociationScope
|
|
26
|
+
extend Torque::PostgreSQL::Associations::AssociationScope::ClassMethods
|
|
27
|
+
prepend Torque::PostgreSQL::Associations::AssociationScope
|
|
28
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
class BelongsToManyAssociation < ::ActiveRecord::Associations::CollectionAssociation
|
|
5
|
+
include ::ActiveRecord::Associations::ForeignAssociation
|
|
6
|
+
|
|
7
|
+
type ids = Array[untyped]
|
|
8
|
+
|
|
9
|
+
@_building_changes: bool?
|
|
10
|
+
@_was_loaded: bool
|
|
11
|
+
|
|
12
|
+
def ids_reader: () -> ids
|
|
13
|
+
def ids_writer: (ids? ids) -> untyped
|
|
14
|
+
def size: () -> Integer
|
|
15
|
+
def empty?: () -> bool
|
|
16
|
+
def include?: (record record) -> untyped
|
|
17
|
+
def load_target: () -> Array[record]
|
|
18
|
+
def build_changes: (?bool from_target) { () -> untyped } -> untyped
|
|
19
|
+
def trigger: (Symbol prefix, ids before_ids, ids after_ids) -> untyped
|
|
20
|
+
def handle_dependency: () -> untyped
|
|
21
|
+
def insert_record: (record record, *untyped) ?{ (?) -> untyped } -> bool
|
|
22
|
+
def default: () { (?) -> untyped } -> untyped
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def _create_record: (Hash[untyped, untyped] | Array[Hash[untyped, untyped]] attributes, ?bool raises) ?{ (record) -> void } -> (record | Array[record])
|
|
27
|
+
def delete_count: (Symbol? method, relation scope, ids ids) -> Integer
|
|
28
|
+
def delete_or_nullify_all_records: (Symbol? method) -> Integer
|
|
29
|
+
def delete_records: (Array[record] records, Symbol? method) -> untyped
|
|
30
|
+
def source_attr: () -> String
|
|
31
|
+
def klass_attr: () -> String
|
|
32
|
+
def read_records_ids: (Array[record] | record | nil records) -> ids?
|
|
33
|
+
def ids_rewriter: (untyped ids, Symbol operator) -> untyped
|
|
34
|
+
def column_default_value: () -> untyped
|
|
35
|
+
def callback: (*untyped) -> true
|
|
36
|
+
def replace_records: (*untyped) -> untyped
|
|
37
|
+
def concat_records: (*untyped) -> untyped
|
|
38
|
+
def delete_or_destroy: (*untyped) -> untyped
|
|
39
|
+
def difference: (Array[untyped] a, Array[untyped] b) -> Array[untyped]
|
|
40
|
+
def intersection: (Array[untyped] a, Array[untyped] b) -> Array[untyped]
|
|
41
|
+
def scope_for_create: () -> Hash[String, untyped]
|
|
42
|
+
def find_target?: () -> untyped
|
|
43
|
+
def foreign_key_present?: () -> bool
|
|
44
|
+
def invertible_for?: (record record) -> untyped
|
|
45
|
+
def stale_state: () -> ids?
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ActiveRecord::Associations::BelongsToManyAssociation = Torque::PostgreSQL::Associations::BelongsToManyAssociation
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module Builder
|
|
5
|
+
class BelongsToMany < ::ActiveRecord::Associations::Builder::CollectionAssociation
|
|
6
|
+
def self.macro: () -> :belongs_to_many
|
|
7
|
+
def self.valid_options: (Hash[Symbol, untyped] options) -> Array[Symbol]
|
|
8
|
+
def self.valid_dependent_options: () -> Array[Symbol]
|
|
9
|
+
def self.define_callbacks: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
10
|
+
def self.define_readers: (Module mixin, Symbol name) -> untyped
|
|
11
|
+
def self.define_writers: (Module mixin, Symbol name) -> untyped
|
|
12
|
+
def self.add_default_callbacks: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
13
|
+
def self.add_touch_callbacks: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
14
|
+
def self.touch_record: (record o, Hash[String, untyped] changes, String foreign_key, Symbol name, bool | Symbol touch, Symbol touch_method) -> untyped
|
|
15
|
+
def self.add_change_callbacks: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
16
|
+
def self.add_destroy_callbacks: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
17
|
+
def self.define_validations: (model model, Reflection::BelongsToManyReflection reflection) -> untyped
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class ActiveRecord::Associations::Builder::BelongsToMany = Torque::PostgreSQL::Associations::Builder::BelongsToMany
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module Builder
|
|
5
|
+
module HasMany
|
|
6
|
+
def valid_options: (Hash[Symbol, untyped] options) -> Array[Symbol]
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class ActiveRecord::Associations::Builder::HasMany
|
|
14
|
+
extend Torque::PostgreSQL::Associations::Builder::HasMany
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module ForeignAssociation
|
|
5
|
+
@inversed: bool
|
|
6
|
+
|
|
7
|
+
def inversed_from: (record record) -> untyped
|
|
8
|
+
def skip_statement_cache?: (*untyped) -> untyped
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def set_owner_attributes: (record record) -> untyped
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module JoinDependency
|
|
5
|
+
def apply_column_aliases: (relation relation) -> untyped
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def cast_join_root?: (relation relation) -> bool
|
|
10
|
+
def root_record_class_marker: () -> ::Arel::Nodes::As
|
|
11
|
+
def joined_record_class_markers: () -> Array[::Arel::Nodes::As]
|
|
12
|
+
def record_class_column_name: () -> String
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module Preloader
|
|
5
|
+
module Association
|
|
6
|
+
@run: bool
|
|
7
|
+
@records_by_owner: Hash[record, Array[record]]
|
|
8
|
+
@preloaded_records: Array[record]
|
|
9
|
+
@owners_by_key: Hash[untyped, Array[record]]
|
|
10
|
+
|
|
11
|
+
def connected_through_array?: () -> untyped
|
|
12
|
+
def run: () -> self
|
|
13
|
+
def set_inverse: (record record) -> untyped
|
|
14
|
+
def load_records: (?Array[record]? raw_records) -> untyped
|
|
15
|
+
def owners_by_key: () -> Hash[untyped, Array[record]]
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def run_array_for_belongs_to_many: () -> untyped
|
|
20
|
+
def run_array_for_has_many: () -> untyped
|
|
21
|
+
def records_for: (Array[untyped] ids) ?{ (record) -> void } -> Array[record]
|
|
22
|
+
def associate_records_to_owner: (record owner, Array[record] records) -> untyped
|
|
23
|
+
def groupped_records: () -> Hash[untyped, Array[record]]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class ActiveRecord::Associations::Preloader::Association
|
|
31
|
+
prepend Torque::PostgreSQL::Associations::Preloader::Association
|
|
32
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
module Preloader
|
|
5
|
+
module LoaderQuery
|
|
6
|
+
@foreign_column: column?
|
|
7
|
+
|
|
8
|
+
def foreign_column: () -> column?
|
|
9
|
+
def load_records_for_keys: (Enumerable[untyped] keys) ?{ (record) -> void } -> (Array[record] | relation)
|
|
10
|
+
def query_condition_for: (Enumerable[untyped] keys) -> arel_node?
|
|
11
|
+
def connected_through_array?: () -> untyped
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class ActiveRecord::Associations::Preloader::Association::LoaderQuery
|
|
19
|
+
prepend Torque::PostgreSQL::Associations::Preloader::LoaderQuery
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Associations
|
|
4
|
+
class BelongsToManyAssociation
|
|
5
|
+
prepend ForeignAssociation
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class ActiveRecord::Associations::HasManyAssociation
|
|
12
|
+
prepend Torque::PostgreSQL::Associations::ForeignAssociation
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ActiveRecord::Associations::JoinDependency
|
|
16
|
+
prepend Torque::PostgreSQL::Associations::JoinDependency
|
|
17
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
class Base
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include ActiveModel::Attributes
|
|
7
|
+
include ActiveModel::Serialization
|
|
8
|
+
include ActiveModel::Serializers::JSON
|
|
9
|
+
include ActiveModel::Dirty
|
|
10
|
+
include ActiveModel::Validations::Callbacks
|
|
11
|
+
include SimpleEnum
|
|
12
|
+
extend SimpleEnum::ClassMethods
|
|
13
|
+
include ActiveRecord::Store
|
|
14
|
+
include ActiveModel::Attributes::Normalization
|
|
15
|
+
include ActiveRecord::Encryption::EncryptableRecord
|
|
16
|
+
|
|
17
|
+
def self.filter_attributes: () -> Array[Symbol | String | Regexp | Proc]
|
|
18
|
+
def self.filter_attributes=: (Array[Symbol | String | Regexp | Proc] value) -> Array[Symbol | String | Regexp | Proc]
|
|
19
|
+
def self.columns_hash: () -> Hash[String, column]
|
|
20
|
+
def self.encrypts: (*column_ref names, **untyped options) -> untyped
|
|
21
|
+
def self.inspection_filter: () -> ActiveSupport::ParameterFilter
|
|
22
|
+
|
|
23
|
+
def inspect: () -> String
|
|
24
|
+
def []: (column_ref key) -> untyped
|
|
25
|
+
def []=: (column_ref key, untyped value) -> untyped
|
|
26
|
+
def ==: (untyped other) -> bool
|
|
27
|
+
alias eql? ==
|
|
28
|
+
def empty?: () -> bool
|
|
29
|
+
def hash: () -> Integer
|
|
30
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
31
|
+
def type_for_attribute: (column_ref name) ?{ (?) -> untyped } -> type_caster
|
|
32
|
+
def read_attribute_before_type_cast: (column_ref name) -> untyped
|
|
33
|
+
def read_attribute_for_database: (column_ref name) -> untyped
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
module Builder
|
|
5
|
+
class Enum
|
|
6
|
+
type methods = Hash[String, [String, String, String, String]]
|
|
7
|
+
|
|
8
|
+
VALID_TYPES: Array[Symbol]
|
|
9
|
+
FN: String
|
|
10
|
+
|
|
11
|
+
attr_accessor klass: model
|
|
12
|
+
attr_accessor attribute: String
|
|
13
|
+
attr_accessor subtype: Adapter::OID::Enum
|
|
14
|
+
attr_accessor options: Hash[Symbol, untyped]
|
|
15
|
+
attr_accessor values: Array[String]
|
|
16
|
+
attr_accessor klass_module: Module?
|
|
17
|
+
attr_accessor instance_module: Module?
|
|
18
|
+
|
|
19
|
+
@values_methods: methods
|
|
20
|
+
|
|
21
|
+
def initialize: (model klass, column_ref attribute, Hash[Symbol, untyped] options) -> void
|
|
22
|
+
def values_methods: () -> methods
|
|
23
|
+
def set_features?: () -> bool
|
|
24
|
+
def conflicting?: () -> untyped
|
|
25
|
+
def build: () -> untyped
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def dangerous?: (String | Symbol method_name, ?bool class_method) -> untyped
|
|
30
|
+
def plural: () -> untyped
|
|
31
|
+
def set_scopes: () -> untyped
|
|
32
|
+
def stringify: () -> untyped
|
|
33
|
+
def all_values: () -> untyped
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
module Builder
|
|
5
|
+
class FullTextSearch
|
|
6
|
+
attr_accessor klass: model
|
|
7
|
+
attr_accessor attribute: column_ref
|
|
8
|
+
attr_accessor options: Hash[Symbol, untyped]
|
|
9
|
+
attr_accessor klass_module: Module?
|
|
10
|
+
attr_accessor default_rank: String?
|
|
11
|
+
attr_accessor default_mode: Symbol
|
|
12
|
+
attr_accessor default_order: (:asc | :desc | false)
|
|
13
|
+
attr_accessor default_language: String | Symbol
|
|
14
|
+
|
|
15
|
+
@scope_name: String
|
|
16
|
+
|
|
17
|
+
def initialize: (model klass, column_ref attribute, ?Hash[Symbol, untyped] options) -> void
|
|
18
|
+
def scope_name: () -> String
|
|
19
|
+
def conflicting?: () -> untyped
|
|
20
|
+
def build: () -> untyped
|
|
21
|
+
def add_scope_to_module: () -> untyped
|
|
22
|
+
def scope_args: () -> String
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
module Builder
|
|
5
|
+
class Period
|
|
6
|
+
type threshold = Symbol | ActiveSupport::Duration | Numeric | nil
|
|
7
|
+
type method_names = Hash[Symbol, String | Symbol]
|
|
8
|
+
|
|
9
|
+
DIRECT_ACCESS_REGEX: Regexp
|
|
10
|
+
SUPPORTED_TYPES: Array[Symbol]
|
|
11
|
+
CURRENT_GETTERS: Hash[Symbol, String]
|
|
12
|
+
TYPE_CASTERS: Hash[Symbol, Symbol]
|
|
13
|
+
FN: String
|
|
14
|
+
|
|
15
|
+
attr_accessor klass: model
|
|
16
|
+
attr_accessor attribute: String
|
|
17
|
+
attr_accessor options: Hash[Symbol, untyped]
|
|
18
|
+
attr_accessor type: Symbol
|
|
19
|
+
attr_accessor default: bool
|
|
20
|
+
attr_accessor current_getter: String
|
|
21
|
+
attr_accessor type_caster: Symbol
|
|
22
|
+
attr_writer threshold: threshold
|
|
23
|
+
attr_accessor dynamic_threshold: untyped
|
|
24
|
+
attr_accessor klass_module: Module?
|
|
25
|
+
attr_accessor instance_module: Module?
|
|
26
|
+
|
|
27
|
+
@threshold: threshold
|
|
28
|
+
@method_names: method_names
|
|
29
|
+
@klass_method_names: method_names
|
|
30
|
+
@instance_method_names: method_names
|
|
31
|
+
@arel_attribute: String
|
|
32
|
+
@arel_default_sql: String
|
|
33
|
+
@arel_threshold_value: String?
|
|
34
|
+
@arel_start_at: String
|
|
35
|
+
@arel_finish_at: String
|
|
36
|
+
@arel_real_start_at: String
|
|
37
|
+
@arel_real_finish_at: String
|
|
38
|
+
@arel_real_attribute: String
|
|
39
|
+
|
|
40
|
+
def initialize: (model klass, column_ref attribute, Hash[Symbol, untyped] options) -> void
|
|
41
|
+
def threshold: () -> threshold
|
|
42
|
+
def method_names: () -> method_names
|
|
43
|
+
def klass_method_names: () -> method_names
|
|
44
|
+
def instance_method_names: () -> method_names
|
|
45
|
+
def conflicting?: () -> untyped
|
|
46
|
+
def build: () -> untyped
|
|
47
|
+
def build_method_helper: (Symbol type, Symbol key, ?Array[String] args) -> untyped
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def default_method_names: () -> method_names
|
|
52
|
+
def dangerous?: (String | Symbol method_name, ?bool class_method) -> untyped
|
|
53
|
+
def define_string_method: (String | Symbol name, String body, ?Array[String] args) -> String
|
|
54
|
+
def arel_attribute: () -> String
|
|
55
|
+
def arel_default_sql: () -> String
|
|
56
|
+
def arel_sql_bind: (String value) -> String
|
|
57
|
+
def arel_threshold_value: () -> String?
|
|
58
|
+
def arel_start_at: () -> String
|
|
59
|
+
def arel_finish_at: () -> String
|
|
60
|
+
def arel_real_start_at: () -> String
|
|
61
|
+
def arel_real_finish_at: () -> String
|
|
62
|
+
def arel_real_attribute: () -> String
|
|
63
|
+
def arel_convert_to_type: (String left, ?String? right, ?Symbol? set_type) -> String
|
|
64
|
+
def arel_named_function: (String | Symbol name, *String args) -> String
|
|
65
|
+
def arel_nullif: (*String args) -> String
|
|
66
|
+
def arel_coalesce: (*String args) -> String
|
|
67
|
+
def arel_empty_value: () -> String
|
|
68
|
+
def arel_daterange: (?bool real) -> String
|
|
69
|
+
def arel_check_condition: (Symbol type) -> String
|
|
70
|
+
def arel_formatting_value: (?String? condition, ?String value, ?cast: Symbol?) -> String
|
|
71
|
+
def arel_formatting_left_right: (String condition, ?Symbol? set_type, ?cast: Symbol?) -> String
|
|
72
|
+
def klass_current_on: () -> String
|
|
73
|
+
def klass_current: () -> String
|
|
74
|
+
def klass_not_current: () -> String
|
|
75
|
+
def klass_containing: () -> String
|
|
76
|
+
def klass_not_containing: () -> String
|
|
77
|
+
def klass_overlapping: () -> String
|
|
78
|
+
def klass_not_overlapping: () -> String
|
|
79
|
+
def klass_starting_after: () -> String
|
|
80
|
+
def klass_starting_before: () -> String
|
|
81
|
+
def klass_finishing_after: () -> String
|
|
82
|
+
def klass_finishing_before: () -> String
|
|
83
|
+
def klass_real_containing: () -> String
|
|
84
|
+
def klass_real_overlapping: () -> String
|
|
85
|
+
def klass_real_starting_after: () -> String
|
|
86
|
+
def klass_real_starting_before: () -> String
|
|
87
|
+
def klass_real_finishing_after: () -> String
|
|
88
|
+
def klass_real_finishing_before: () -> String
|
|
89
|
+
def klass_containing_date: () -> String
|
|
90
|
+
def klass_not_containing_date: () -> String
|
|
91
|
+
def klass_overlapping_date: () -> String
|
|
92
|
+
def klass_not_overlapping_date: () -> String
|
|
93
|
+
def klass_real_containing_date: () -> String
|
|
94
|
+
def klass_real_overlapping_date: () -> String
|
|
95
|
+
def instance_current?: () -> String
|
|
96
|
+
def instance_current_on?: () -> String
|
|
97
|
+
def instance_start: () -> String
|
|
98
|
+
def instance_finish: () -> String
|
|
99
|
+
def instance_real: () -> String
|
|
100
|
+
def instance_real_start: () -> String
|
|
101
|
+
def instance_real_finish: () -> String
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# The macros these builders install on models (torque_enum, torque_enum_set,
|
|
2
|
+
# period_for, torque_search_for, struct_for) are declared under their default
|
|
3
|
+
# names next to each feature. The per-attribute methods they generate, like
|
|
4
|
+
# `roles`, `admin?`, the period scopes and the search scope, depend on the
|
|
5
|
+
# model's columns and on config, so RBS cannot express them.
|
|
6
|
+
module Torque
|
|
7
|
+
module PostgreSQL
|
|
8
|
+
module Attributes
|
|
9
|
+
module Builder
|
|
10
|
+
type builder_class = singleton(Enum) | singleton(Period) | singleton(FullTextSearch)
|
|
11
|
+
|
|
12
|
+
def self.include_on: (model klass, Symbol method_name, builder_class builder_klass, **untyped extra) ?{ (Enum | Period | FullTextSearch builder) -> void } -> untyped
|
|
13
|
+
def self.search_vector_options: (columns: Adapter::search_columns, ?language: String | Symbol | nil, ?stored: bool, **untyped options) -> Hash[Symbol, untyped]
|
|
14
|
+
def self.to_search_weights: (Adapter::search_columns columns) -> Hash[String, String]
|
|
15
|
+
def self.to_search_vector_operation: (String | Symbol | nil language, Hash[String, String] weights) -> arel_node
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
class Composite < Base
|
|
5
|
+
@type_name: String
|
|
6
|
+
@columns: Hash[String, type_caster]
|
|
7
|
+
@load_columns_monitor: Monitor
|
|
8
|
+
|
|
9
|
+
def self.type_name=: (String value) -> String
|
|
10
|
+
def self.lookup: (table_ref name) -> singleton(Composite)
|
|
11
|
+
def self.inherited: (singleton(Composite) subclass) -> untyped
|
|
12
|
+
def self.type_name: () -> String
|
|
13
|
+
def self.columns: () -> Hash[String, type_caster]?
|
|
14
|
+
def self.load_columns: () -> untyped
|
|
15
|
+
def self.reset_columns!: () -> untyped
|
|
16
|
+
def self.new: (*untyped args, **untyped xargs) ?{ (?) -> untyped } -> instance
|
|
17
|
+
def self.encrypts: (*column_ref names, **untyped options) -> untyped
|
|
18
|
+
def self.enum: (column_ref name, ?SimpleEnum::values values, **untyped options) -> untyped
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def self.resolve: (singleton(Composite) klass, String name) -> singleton(Composite)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Composite = Attributes::Composite
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Torque
|
|
2
|
+
module PostgreSQL
|
|
3
|
+
module Attributes
|
|
4
|
+
class Enum < String
|
|
5
|
+
include Comparable
|
|
6
|
+
extend Enumerable[untyped]
|
|
7
|
+
|
|
8
|
+
class EnumError < ArgumentError
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
LAZY_VALUE: String
|
|
12
|
+
|
|
13
|
+
@values: Array[String]
|
|
14
|
+
@type_name: String
|
|
15
|
+
@load_values_monitor: Monitor
|
|
16
|
+
|
|
17
|
+
def self.each: (*untyped) ?{ (instance) -> untyped } -> untyped
|
|
18
|
+
def self.sample: (*untyped) -> instance?
|
|
19
|
+
def self.size: () -> Integer
|
|
20
|
+
def self.length: () -> Integer
|
|
21
|
+
def self.lookup: (table_ref name) -> singleton(Enum)
|
|
22
|
+
def self.include_on: (model klass, ?Symbol? method_name) -> untyped
|
|
23
|
+
def self.new: (untyped value) -> untyped
|
|
24
|
+
def self.inherited: (singleton(Enum) subclass) -> untyped
|
|
25
|
+
def self.values: () -> Array[String]?
|
|
26
|
+
def self.keys: () -> Array[Symbol]
|
|
27
|
+
def self.members: () -> Array[instance]
|
|
28
|
+
def self.texts: () -> Array[String]
|
|
29
|
+
def self.to_options: () -> Array[[String, String]]
|
|
30
|
+
def self.fetch: (String | Symbol value, *untyped) -> instance?
|
|
31
|
+
alias self.[] self.fetch
|
|
32
|
+
def self.type_name: () -> String
|
|
33
|
+
def self.valid?: (untyped value) -> bool
|
|
34
|
+
def self.scope: (arel_attribute attribute, String | Symbol value) -> ::Arel::Nodes::Equality
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def self.respond_to_missing?: (Symbol method_name, ?bool include_private) -> bool
|
|
39
|
+
def self.method_missing: (Symbol method_name, *untyped arguments) -> untyped
|
|
40
|
+
|
|
41
|
+
public
|
|
42
|
+
|
|
43
|
+
def initialize: (untyped value) -> void
|
|
44
|
+
def <=>: (untyped other) -> Integer?
|
|
45
|
+
def ==: (untyped other) -> bool
|
|
46
|
+
alias eql? ==
|
|
47
|
+
def nil?: () -> bool
|
|
48
|
+
alias empty? nil?
|
|
49
|
+
def replace: (String | Symbol value) -> self
|
|
50
|
+
def text: (?column_ref? attr, ?untyped model) -> String
|
|
51
|
+
def to_s: () -> String
|
|
52
|
+
def to_i: () -> Integer?
|
|
53
|
+
def inspect: () -> String
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def i18n_keys: (?column_ref? attr, ?untyped model) -> Array[Symbol]
|
|
58
|
+
def respond_to_missing?: (Symbol method_name, ?bool include_private) -> untyped
|
|
59
|
+
def method_missing: (Symbol method_name, *untyped arguments) -> untyped
|
|
60
|
+
def raise_invalid: (untyped value) -> bot
|
|
61
|
+
def raise_comparison: (untyped other) -> bot
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class ActiveRecord::Base
|
|
68
|
+
def self.torque_enum: (*Torque::PostgreSQL::column_ref attributes, ?only: Array[Torque::PostgreSQL::column_ref] | Torque::PostgreSQL::column_ref, ?except: Array[Torque::PostgreSQL::column_ref] | Torque::PostgreSQL::column_ref, ?prefix: bool | Torque::PostgreSQL::column_ref, ?suffix: bool | Torque::PostgreSQL::column_ref, ?force: bool) -> untyped
|
|
69
|
+
end
|