rom-sql 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/circle.yml +1 -1
- data/lib/rom/plugins/relation/sql/auto_combine.rb +1 -1
- data/lib/rom/sql/association.rb +5 -1
- data/lib/rom/sql/association/many_to_many.rb +8 -4
- data/lib/rom/sql/association/many_to_one.rb +2 -3
- data/lib/rom/sql/association/one_to_many.rb +2 -3
- data/lib/rom/sql/commands/create.rb +8 -1
- data/lib/rom/sql/commands/update.rb +7 -0
- data/lib/rom/sql/extensions.rb +8 -0
- data/lib/rom/sql/extensions/active_support_notifications.rb +7 -18
- data/lib/rom/sql/extensions/mysql.rb +1 -0
- data/lib/rom/sql/extensions/mysql/inferrer.rb +10 -0
- data/lib/rom/sql/extensions/postgres/commands.rb +1 -1
- data/lib/rom/sql/extensions/postgres/inferrer.rb +4 -0
- data/lib/rom/sql/extensions/postgres/types.rb +20 -22
- data/lib/rom/sql/extensions/sqlite.rb +1 -0
- data/lib/rom/sql/extensions/sqlite/inferrer.rb +10 -0
- data/lib/rom/sql/function.rb +6 -2
- data/lib/rom/sql/order_dsl.rb +1 -1
- data/lib/rom/sql/plugin/associates.rb +28 -5
- data/lib/rom/sql/relation.rb +18 -0
- data/lib/rom/sql/relation/reading.rb +2 -2
- data/lib/rom/sql/relation/sequel_api.rb +119 -0
- data/lib/rom/sql/schema/inferrer.rb +26 -2
- data/lib/rom/sql/tasks/migration_tasks.rake +1 -1
- data/lib/rom/sql/type.rb +13 -2
- data/lib/rom/sql/types.rb +5 -3
- data/lib/rom/sql/version.rb +1 -1
- data/spec/extensions/postgres/types_spec.rb +29 -0
- data/spec/integration/association/many_to_many_spec.rb +8 -0
- data/spec/integration/association/many_to_one_spec.rb +11 -0
- data/spec/integration/association/one_to_many_spec.rb +9 -0
- data/spec/integration/schema/inferrer/mysql_spec.rb +36 -0
- data/spec/integration/schema/inferrer/postgres_spec.rb +118 -0
- data/spec/integration/schema/inferrer/sqlite_spec.rb +36 -0
- data/spec/integration/{schema_inference_spec.rb → schema/inferrer_spec.rb} +44 -15
- data/spec/integration/sequel_api_spec.rb +31 -0
- data/spec/support/helpers.rb +4 -0
- data/spec/unit/function_spec.rb +35 -0
- data/spec/unit/order_dsl_spec.rb +35 -0
- data/spec/unit/relation/assoc_spec.rb +38 -0
- data/spec/unit/relation/inner_join_spec.rb +15 -0
- data/spec/unit/types_spec.rb +53 -1
- metadata +23 -6
- data/spec/extensions/postgres/inferrer_spec.rb +0 -59
@@ -1,59 +0,0 @@
|
|
1
|
-
RSpec.describe 'ROM::SQL::Schema::PostgresInferrer', :postgres do
|
2
|
-
include_context 'database setup'
|
3
|
-
|
4
|
-
colors = %w(red orange yellow green blue purple)
|
5
|
-
|
6
|
-
before do
|
7
|
-
conn.extension :pg_enum
|
8
|
-
|
9
|
-
conn.drop_table?(:test_inferrence)
|
10
|
-
conn.drop_enum(:rainbow, if_exists: true)
|
11
|
-
|
12
|
-
conn.create_enum(:rainbow, colors)
|
13
|
-
|
14
|
-
conn.create_table :test_inferrence do
|
15
|
-
primary_key :id, :uuid
|
16
|
-
Json :json_data
|
17
|
-
Jsonb :jsonb_data
|
18
|
-
Decimal :money, null: false
|
19
|
-
column :tags, "text[]"
|
20
|
-
column :tag_ids, "bigint[]"
|
21
|
-
column :ip, "inet"
|
22
|
-
rainbow :color
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
after do
|
27
|
-
conn.drop_table?(:test_inferrence)
|
28
|
-
end
|
29
|
-
|
30
|
-
let(:dataset) { :test_inferrence }
|
31
|
-
|
32
|
-
let(:schema) { container.relations[dataset].schema }
|
33
|
-
|
34
|
-
context 'inferring db-specific attributes' do
|
35
|
-
before do
|
36
|
-
dataset = self.dataset
|
37
|
-
conf.relation(dataset) do
|
38
|
-
schema(dataset, infer: true) do
|
39
|
-
attribute :ip, ROM::SQL::Types::String
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'can infer attributes for dataset' do
|
45
|
-
source = container.relations[:test_inferrence].name
|
46
|
-
|
47
|
-
expect(schema.to_h).to eql(
|
48
|
-
id: ROM::SQL::Types::PG::UUID.meta(name: :id, source: source, primary_key: true),
|
49
|
-
json_data: ROM::SQL::Types::PG::JSON.optional.meta(name: :json_data, source: source),
|
50
|
-
jsonb_data: ROM::SQL::Types::PG::JSONB.optional.meta(name: :jsonb_data, source: source),
|
51
|
-
money: ROM::SQL::Types::Decimal.meta(name: :money, source: source),
|
52
|
-
tags: ROM::SQL::Types::PG::Array('text').optional.meta(name: :tags, source: source),
|
53
|
-
tag_ids: ROM::SQL::Types::PG::Array('biging').optional.meta(name: :tag_ids, source: source),
|
54
|
-
color: ROM::SQL::Types::String.enum(*colors).optional.meta(name: :color, source: source),
|
55
|
-
ip: ROM::SQL::Types::String.meta(name: :ip, source: source)
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|