rasti-db 0.1.0 → 0.2.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/lib/rasti/db/query.rb +1 -1
- data/lib/rasti/db/version.rb +1 -1
- data/rasti-db.gemspec +1 -1
- data/spec/collection_spec.rb +4 -4
- data/spec/minitest_helper.rb +1 -1
- data/spec/query_spec.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ab65952edd3d755127be36c3e95655fcf230900
|
4
|
+
data.tar.gz: 58e110b0bc077663cc4ca7b8f2a53167c68bf8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d880a6ab0e060fc7917a980249be459f209e11d607ecf79289cb7d68f05dff209476502da842613a9d434503282d20f2bba78fbe5fd4f51986fa650e6d9bc29
|
7
|
+
data.tar.gz: cffd9d898ceaac6aa3a316e4a9d34249549e008cb7ba43d2945d55c2d8beb6bc1c66abf84cafae95ccaf7ed88fbd7f70dea4d0610e282d0e95269e335763270b
|
data/lib/rasti/db/query.rb
CHANGED
@@ -2,7 +2,7 @@ module Rasti
|
|
2
2
|
module DB
|
3
3
|
class Query
|
4
4
|
|
5
|
-
DATASET_CHAINED_METHODS = [:where, :exclude, :
|
5
|
+
DATASET_CHAINED_METHODS = [:where, :exclude, :or, :order, :reverse_order, :limit, :offset].freeze
|
6
6
|
|
7
7
|
include Enumerable
|
8
8
|
include Helpers::WithSchema
|
data/lib/rasti/db/version.rb
CHANGED
data/rasti-db.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'sequel', '~>
|
21
|
+
spec.add_runtime_dependency 'sequel', '~> 5.0'
|
22
22
|
spec.add_runtime_dependency 'consty', '~> 1.0'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
data/spec/collection_spec.rb
CHANGED
@@ -208,16 +208,16 @@ describe 'Collection' do
|
|
208
208
|
db[:users].where(id: 1).count.must_equal 1
|
209
209
|
db[:comments].where(user_id: 1).count.must_equal 3
|
210
210
|
db[:posts].where(user_id: 1).count.must_equal 3
|
211
|
-
db[:comments].join(:posts, id: :post_id).where(
|
212
|
-
db[:categories_posts].join(:posts, id: :post_id).where(
|
211
|
+
db[:comments].join(:posts, id: :post_id).where(Sequel.qualify(:posts, :user_id) => 1).count.must_equal 3
|
212
|
+
db[:categories_posts].join(:posts, id: :post_id).where(Sequel.qualify(:posts, :user_id) => 1).count.must_equal 3
|
213
213
|
|
214
214
|
users.delete_cascade 1
|
215
215
|
|
216
216
|
db[:users].where(id: 1).count.must_equal 0
|
217
217
|
db[:comments].where(user_id: 1).count.must_equal 0
|
218
218
|
db[:posts].where(user_id: 1).count.must_equal 0
|
219
|
-
db[:comments].join(:posts, id: :post_id).where(
|
220
|
-
db[:categories_posts].join(:posts, id: :post_id).where(
|
219
|
+
db[:comments].join(:posts, id: :post_id).where(Sequel.qualify(:posts, :user_id) => 1).count.must_equal 0
|
220
|
+
db[:categories_posts].join(:posts, id: :post_id).where(Sequel.qualify(:posts, :user_id) => 1).count.must_equal 0
|
221
221
|
|
222
222
|
db[:users].count.must_equal 2
|
223
223
|
db[:categories].count.must_equal 3
|
data/spec/minitest_helper.rb
CHANGED
@@ -45,7 +45,7 @@ class Comments < Rasti::DB::Collection
|
|
45
45
|
many_to_one :post
|
46
46
|
|
47
47
|
def posts_commented_by(user_id)
|
48
|
-
dataset.where(
|
48
|
+
dataset.where(Sequel.qualify(:comments, :user_id) => user_id)
|
49
49
|
.join(with_schema(:posts), id: :post_id)
|
50
50
|
.select_all(with_schema(:posts))
|
51
51
|
.map { |row| Post.new row }
|
data/spec/query_spec.rb
CHANGED
@@ -49,7 +49,7 @@ describe 'Query' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'And' do
|
52
|
-
users_query.where(id: [1,2]).
|
52
|
+
users_query.where(id: [1,2]).where(name: 'User 2').all.must_equal [User.new(id: 2, name: 'User 2')]
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'Or' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasti-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: consty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|