torque-postgresql 0.2.12 → 0.2.13
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/torque/postgresql/adapter.rb +1 -1
- data/lib/torque/postgresql/adapter/database_statements.rb +15 -4
- data/lib/torque/postgresql/adapter/oid/interval.rb +1 -1
- data/lib/torque/postgresql/adapter/schema_definitions.rb +7 -1
- data/lib/torque/postgresql/adapter/schema_dumper.rb +5 -3
- data/lib/torque/postgresql/config.rb +3 -0
- data/lib/torque/postgresql/relation.rb +1 -1
- data/lib/torque/postgresql/relation/auxiliary_statement.rb +9 -4
- data/lib/torque/postgresql/relation/distinct_on.rb +2 -2
- data/lib/torque/postgresql/relation/inheritance.rb +1 -1
- data/lib/torque/postgresql/schema_dumper.rb +7 -1
- data/lib/torque/postgresql/version.rb +1 -1
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a19c0e5178591e3b9ea84d11df0b21d34f135df
|
4
|
+
data.tar.gz: 06c0b78395434ae948854222ce3ad015ce55cd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90146d035616baa734f5a068028b32bf5a9605539d1f58a76f8ce107b65eeeaed8e88776d6bde29460ab340667b96a14fbf0e18f196c98d805f479511a5db167
|
7
|
+
data.tar.gz: f5f126cf74c95a4c3ccb4d6aab8f69c82a5e37215ea79928d2bc261f819d00db8c6721e059e954c9dd353182a74794c31668630ce58dac49f6274c5a113d919f
|
@@ -33,15 +33,26 @@ module Torque
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Change some of the types being mapped
|
36
|
-
def initialize_type_map(m)
|
36
|
+
def initialize_type_map(m = type_map)
|
37
37
|
super
|
38
38
|
m.register_type 'interval', OID::Interval.new
|
39
39
|
end
|
40
40
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
41
|
+
# :nodoc:
|
42
|
+
if Torque::PostgreSQL::AR521
|
43
|
+
def load_additional_types(oids = nil)
|
44
|
+
super
|
45
|
+
torque_load_additional_types(oids)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
def load_additional_types(type_map, oids = nil)
|
49
|
+
super
|
50
|
+
torque_load_additional_types(oids)
|
51
|
+
end
|
52
|
+
end
|
44
53
|
|
54
|
+
# Add the composite types to be loaded too.
|
55
|
+
def torque_load_additional_types(oids = nil)
|
45
56
|
filter = "AND a.typelem::integer IN (%s)" % oids.join(", ") if oids
|
46
57
|
|
47
58
|
query = <<-SQL
|
@@ -3,10 +3,16 @@ module Torque
|
|
3
3
|
module Adapter
|
4
4
|
module ColumnMethods
|
5
5
|
|
6
|
+
# Creates a column with an interval type, allowing span of times and
|
7
|
+
# dates to be stored without having to store a seconds-based integer
|
8
|
+
# or any sort of other approach
|
6
9
|
def interval(*args, **options)
|
7
10
|
args.each { |name| column(name, :interval, options) }
|
8
11
|
end
|
9
12
|
|
13
|
+
# Creates a column with an enum type, needing to specify the subtype,
|
14
|
+
# which is basically the name of the type defined prior creating the
|
15
|
+
# column
|
10
16
|
def enum(*args, **options)
|
11
17
|
args.each do |name|
|
12
18
|
type = options.fetch(:subtype, name)
|
@@ -21,7 +27,7 @@ module Torque
|
|
21
27
|
|
22
28
|
attr_reader :inherits
|
23
29
|
|
24
|
-
def initialize(name, *
|
30
|
+
def initialize(name, *_, **options)
|
25
31
|
old_args = []
|
26
32
|
old_args << options.delete(:temporary) || false
|
27
33
|
old_args << options.delete(:options)
|
@@ -4,8 +4,10 @@ module Torque
|
|
4
4
|
module ColumnDumper
|
5
5
|
|
6
6
|
# Adds +:subtype+ as a valid migration key
|
7
|
-
|
8
|
-
|
7
|
+
unless Torque::PostgreSQL::AR521
|
8
|
+
def migration_keys
|
9
|
+
super + [:subtype]
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
# Adds +:subtype+ option to the default set
|
@@ -22,7 +24,7 @@ module Torque
|
|
22
24
|
private
|
23
25
|
|
24
26
|
def schema_subtype(column)
|
25
|
-
column.sql_type.to_sym.inspect if
|
27
|
+
column.sql_type.to_sym.inspect if column.type == :enum
|
26
28
|
end
|
27
29
|
|
28
30
|
end
|
@@ -2,6 +2,9 @@ module Torque
|
|
2
2
|
module PostgreSQL
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
+
# Stores a version check for compatibility purposes
|
6
|
+
AR521 = (ActiveRecord.gem_version >= Gem::Version.new('5.2.1'))
|
7
|
+
|
5
8
|
# Allow nested configurations
|
6
9
|
# :TODO: Rely on +inheritable_copy+ to make nested configurations
|
7
10
|
config.define_singleton_method(:nested) do |name, &block|
|
@@ -33,15 +33,20 @@ module Torque
|
|
33
33
|
# Get all auxiliary statements bound attributes and the base bound
|
34
34
|
# attributes as well
|
35
35
|
def bound_attributes
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
if Torque::PostgreSQL::AR521
|
37
|
+
visitor = ::Arel::Visitors::PostgreSQL.new(ActiveRecord::Base.connection)
|
38
|
+
visitor.accept(self.arel.ast, ::Arel::Collectors::Bind.new).value
|
39
|
+
else
|
40
|
+
return super unless self.auxiliary_statements_values.present?
|
41
|
+
bindings = self.auxiliary_statements_values.map(&:bound_attributes)
|
42
|
+
(bindings + super).flatten
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
48
|
# Hook arel build to add the distinct on clause
|
44
|
-
def build_arel
|
49
|
+
def build_arel(*)
|
45
50
|
arel = super
|
46
51
|
build_auxiliary_statements(arel)
|
47
52
|
arel
|
@@ -32,8 +32,8 @@ module Torque
|
|
32
32
|
private
|
33
33
|
|
34
34
|
# Hook arel build to add the distinct on clause
|
35
|
-
def build_arel
|
36
|
-
arel = super
|
35
|
+
def build_arel(*)
|
36
|
+
arel = Torque::PostgreSQL::AR521 ? super : super()
|
37
37
|
value = self.distinct_on_values
|
38
38
|
arel.distinct_on(resolve_column(value)) if value.present?
|
39
39
|
arel
|
@@ -2,6 +2,8 @@ module Torque
|
|
2
2
|
module PostgreSQL
|
3
3
|
module SchemaDumper
|
4
4
|
|
5
|
+
include Adapter::ColumnDumper if Torque::PostgreSQL::AR521
|
6
|
+
|
5
7
|
def dump(stream) # :nodoc:
|
6
8
|
@connection.dump_mode!
|
7
9
|
super
|
@@ -80,6 +82,10 @@ module Torque
|
|
80
82
|
|
81
83
|
end
|
82
84
|
|
83
|
-
|
85
|
+
if Torque::PostgreSQL::AR521
|
86
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend SchemaDumper
|
87
|
+
else
|
88
|
+
ActiveRecord::SchemaDumper.prepend SchemaDumper
|
89
|
+
end
|
84
90
|
end
|
85
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.0'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '5.0'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: pg
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|