rom-sql 0.5.3 → 0.6.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/lib/rom/sql.rb +3 -44
- data/lib/rom/sql/error.rb +13 -0
- data/lib/rom/sql/errors.rb +21 -0
- data/lib/rom/sql/plugin/pagination.rb +0 -2
- data/lib/rom/sql/plugins.rb +9 -0
- data/lib/rom/sql/version.rb +1 -1
- data/rom-sql.gemspec +1 -1
- data/spec/spec_helper.rb +3 -1
- data/spec/unit/plugin/pagination_spec.rb +2 -2
- metadata +9 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f021e93524b9b69f53f28b06b664c5b118ff3756
|
4
|
+
data.tar.gz: 37721788b60206c7db1874ca725197eac7bd11d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f402a0f8c0e292e759a586fae0e7d3ac00bb53867ca1217a7a8415006be7c47b4118bb65059ae816784fd28048faf2a20fd9aa772240eb4e70d8e7f741a9fae
|
7
|
+
data.tar.gz: ece947688c9b65010aee26585bfbb07650db44414a6b8c1b8fc5b209664761e19c7953b760d374032b4fbe5a24b2cfa7ed6b788d1be4f76976026067d6d74d71
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -6,6 +6,8 @@ group :test do
|
|
6
6
|
gem 'byebug', platforms: :mri
|
7
7
|
gem 'anima'
|
8
8
|
gem 'rom', github: 'rom-rb/rom', branch: 'master'
|
9
|
+
gem 'rom-support', github: 'rom-rb/rom-support', branch: 'master'
|
10
|
+
gem 'rom-mapper', github: 'rom-rb/rom-mapper', branch: 'master'
|
9
11
|
gem 'virtus'
|
10
12
|
gem 'activesupport'
|
11
13
|
gem 'rspec', '~> 3.1'
|
data/lib/rom/sql.rb
CHANGED
@@ -1,57 +1,16 @@
|
|
1
1
|
require "sequel"
|
2
2
|
require "rom"
|
3
3
|
|
4
|
-
module ROM
|
5
|
-
module SQL
|
6
|
-
NoAssociationError = Class.new(StandardError)
|
7
|
-
|
8
|
-
class Error < StandardError
|
9
|
-
attr_reader :original_exception
|
10
|
-
|
11
|
-
def initialize(original_exception)
|
12
|
-
super(original_exception.message)
|
13
|
-
@original_exception = original_exception
|
14
|
-
set_backtrace(original_exception.backtrace)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
DatabaseError = Class.new(Error)
|
19
|
-
|
20
|
-
ConstraintError = Class.new(Error)
|
21
|
-
|
22
|
-
NotNullConstraintError = Class.new(ConstraintError)
|
23
|
-
UniqueConstraintError = Class.new(ConstraintError)
|
24
|
-
ForeignKeyConstraintError = Class.new(ConstraintError)
|
25
|
-
CheckConstraintError = Class.new(ConstraintError)
|
26
|
-
|
27
|
-
ERROR_MAP = {
|
28
|
-
Sequel::DatabaseError => DatabaseError,
|
29
|
-
Sequel::NotNullConstraintViolation => NotNullConstraintError,
|
30
|
-
Sequel::UniqueConstraintViolation => UniqueConstraintError,
|
31
|
-
Sequel::ForeignKeyConstraintViolation => ForeignKeyConstraintError,
|
32
|
-
Sequel::CheckConstraintViolation => CheckConstraintError
|
33
|
-
}.freeze
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
require 'rom/sql/plugin/associates'
|
38
|
-
require 'rom/sql/plugin/pagination'
|
39
|
-
|
40
|
-
ROM.plugins do
|
41
|
-
adapter :sql do
|
42
|
-
register :pagination, ROM::SQL::Plugin::Pagination, type: :relation
|
43
|
-
register :associates, ROM::SQL::Plugin::Associates, type: :command
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
4
|
require "rom/sql/version"
|
5
|
+
require "rom/sql/errors"
|
6
|
+
require "rom/sql/plugins"
|
48
7
|
require "rom/sql/relation"
|
49
8
|
require "rom/sql/gateway"
|
50
9
|
require "rom/sql/migration"
|
51
10
|
|
52
11
|
if defined?(Rails)
|
53
12
|
require "rom/sql/support/active_support_notifications"
|
54
|
-
require
|
13
|
+
require "rom/sql/support/rails_log_subscriber"
|
55
14
|
end
|
56
15
|
|
57
16
|
ROM.register_adapter(:sql, ROM::SQL)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ROM
|
2
|
+
module SQL
|
3
|
+
class Error < StandardError
|
4
|
+
attr_reader :original_exception
|
5
|
+
|
6
|
+
def initialize(original_exception)
|
7
|
+
super(original_exception.message)
|
8
|
+
@original_exception = original_exception
|
9
|
+
set_backtrace(original_exception.backtrace)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rom/sql/error"
|
2
|
+
|
3
|
+
module ROM
|
4
|
+
module SQL
|
5
|
+
NoAssociationError = Class.new(StandardError)
|
6
|
+
DatabaseError = Class.new(Error)
|
7
|
+
ConstraintError = Class.new(Error)
|
8
|
+
NotNullConstraintError = Class.new(ConstraintError)
|
9
|
+
UniqueConstraintError = Class.new(ConstraintError)
|
10
|
+
ForeignKeyConstraintError = Class.new(ConstraintError)
|
11
|
+
CheckConstraintError = Class.new(ConstraintError)
|
12
|
+
|
13
|
+
ERROR_MAP = {
|
14
|
+
Sequel::DatabaseError => DatabaseError,
|
15
|
+
Sequel::NotNullConstraintViolation => NotNullConstraintError,
|
16
|
+
Sequel::UniqueConstraintViolation => UniqueConstraintError,
|
17
|
+
Sequel::ForeignKeyConstraintViolation => ForeignKeyConstraintError,
|
18
|
+
Sequel::CheckConstraintViolation => CheckConstraintError
|
19
|
+
}.freeze
|
20
|
+
end
|
21
|
+
end
|
data/lib/rom/sql/version.rb
CHANGED
data/rom-sql.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "sequel", "~> 4.18"
|
22
22
|
spec.add_runtime_dependency "equalizer", "~> 0.0", ">= 0.0.9"
|
23
|
-
spec.add_runtime_dependency "rom", "~> 0.
|
23
|
+
spec.add_runtime_dependency "rom", "~> 0.9.0.beta1"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/spec/spec_helper.rb
CHANGED
@@ -21,6 +21,8 @@ begin
|
|
21
21
|
rescue LoadError
|
22
22
|
end
|
23
23
|
|
24
|
+
ROM.use :auto_registration
|
25
|
+
|
24
26
|
LOGGER = Logger.new(File.open('./log/test.log', 'a'))
|
25
27
|
DB_URI = 'postgres://localhost/rom'
|
26
28
|
|
@@ -43,6 +45,6 @@ RSpec.configure do |config|
|
|
43
45
|
config.after do
|
44
46
|
added_constants = Object.constants - @constants
|
45
47
|
added_constants.each { |name| Object.send(:remove_const, name) }
|
46
|
-
ROM.instance_variable_set('@gateways', {})
|
48
|
+
ROM.instance_variable_get('@environment').instance_variable_set('@gateways', {})
|
47
49
|
end
|
48
50
|
end
|
@@ -39,8 +39,8 @@ describe 'Plugin / Pagination' do
|
|
39
39
|
it 'returns paginated relation with provided limit' do
|
40
40
|
users = rom.relation(:users).page(2).per_page(5)
|
41
41
|
|
42
|
-
expect(users.
|
43
|
-
expect(users.
|
42
|
+
expect(users.dataset.opts[:offset]).to eql(5)
|
43
|
+
expect(users.dataset.opts[:limit]).to eql(5)
|
44
44
|
|
45
45
|
expect(users.pager.current_page).to eql(2)
|
46
46
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -50,20 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.8.0
|
53
|
+
version: 0.9.0.beta1
|
57
54
|
type: :runtime
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
58
|
- - "~>"
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.8.0
|
60
|
+
version: 0.9.0.beta1
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
62
|
name: bundler
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +113,8 @@ files:
|
|
119
113
|
- lib/rom/sql/commands/transaction.rb
|
120
114
|
- lib/rom/sql/commands/update.rb
|
121
115
|
- lib/rom/sql/commands_ext/postgres.rb
|
116
|
+
- lib/rom/sql/error.rb
|
117
|
+
- lib/rom/sql/errors.rb
|
122
118
|
- lib/rom/sql/gateway.rb
|
123
119
|
- lib/rom/sql/header.rb
|
124
120
|
- lib/rom/sql/migration.rb
|
@@ -126,6 +122,7 @@ files:
|
|
126
122
|
- lib/rom/sql/migration/template.rb
|
127
123
|
- lib/rom/sql/plugin/associates.rb
|
128
124
|
- lib/rom/sql/plugin/pagination.rb
|
125
|
+
- lib/rom/sql/plugins.rb
|
129
126
|
- lib/rom/sql/rake_task.rb
|
130
127
|
- lib/rom/sql/relation.rb
|
131
128
|
- lib/rom/sql/relation/associations.rb
|
@@ -178,9 +175,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
175
|
version: '0'
|
179
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
177
|
requirements:
|
181
|
-
- - "
|
178
|
+
- - ">"
|
182
179
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
180
|
+
version: 1.3.1
|
184
181
|
requirements: []
|
185
182
|
rubyforge_project:
|
186
183
|
rubygems_version: 2.4.5
|