dbee-active_record 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75589214484b7918c7ae021e2f1cc2815c44b0fd472e61668197f96acb730031
|
4
|
+
data.tar.gz: a5155b0007182721e669a1930b4f313a28b19935b83b7a0084cbc7c65db07d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 609909bbc0f1baab5d1dd36296ef86d47aac62f6f13e1a22d8bd674dacd22212e26e16d213fea797e31f90b8c90c1e78738596dad6b3c8b6d1da32ad82dbc476
|
7
|
+
data.tar.gz: c4815033dd066cd1c99faa3e0887467ec017400305bf0046041ec5b689d5b6c14b97ab5ec3d01a5c34bc6d88ad2bbe9089573ba6a92ad823b202a58418f445c0
|
data/CHANGELOG.md
CHANGED
@@ -19,6 +19,8 @@ module Dbee
|
|
19
19
|
class ExpressionBuilder
|
20
20
|
extend Forwardable
|
21
21
|
|
22
|
+
class MissingConstraintError < StandardError; end
|
23
|
+
|
22
24
|
def_delegators :statement, :to_sql
|
23
25
|
|
24
26
|
def initialize(model, table_alias_maker, column_alias_maker)
|
@@ -127,8 +129,10 @@ module Dbee
|
|
127
129
|
|
128
130
|
on = constraint_maker.make(model.constraints, table, previous_table)
|
129
131
|
|
132
|
+
raise MissingConstraintError, "for: #{name}" unless on
|
133
|
+
|
130
134
|
@statement = statement.join(table, ::Arel::Nodes::OuterJoin)
|
131
|
-
@statement = statement.on(on)
|
135
|
+
@statement = statement.on(on)
|
132
136
|
|
133
137
|
tables[name] = table
|
134
138
|
end
|
@@ -13,6 +13,35 @@ require 'db_helper'
|
|
13
13
|
describe Dbee::Providers::ActiveRecordProvider do
|
14
14
|
let(:models) { yaml_fixture('models.yaml') }
|
15
15
|
|
16
|
+
describe '#sql' do
|
17
|
+
before(:all) do
|
18
|
+
connect_to_db(:sqlite)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'errors when joining tables with no constraints' do
|
22
|
+
model_hash = {
|
23
|
+
name: :users,
|
24
|
+
models: [
|
25
|
+
{ name: :logins }
|
26
|
+
]
|
27
|
+
}
|
28
|
+
|
29
|
+
query_hash = {
|
30
|
+
fields: [
|
31
|
+
{ key_path: 'id' },
|
32
|
+
{ key_path: 'logins.id' }
|
33
|
+
]
|
34
|
+
}
|
35
|
+
|
36
|
+
query = Dbee::Query.make(query_hash)
|
37
|
+
model = Dbee::Model.make(model_hash)
|
38
|
+
|
39
|
+
error_class = Dbee::Providers::ActiveRecordProvider::ExpressionBuilder::MissingConstraintError
|
40
|
+
|
41
|
+
expect { described_class.new.sql(model, query) }.to raise_error(error_class)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
16
45
|
describe 'Snapshot' do
|
17
46
|
context 'Generating SQL' do
|
18
47
|
%w[sqlite mysql].each do |dbms|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbee-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.2.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 5.2.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: dbee
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|