rom-sql 2.3.0 → 2.4.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 +5 -5
- data/CHANGELOG.md +9 -0
- data/lib/rom/sql/extensions/postgres/commands.rb +1 -1
- data/lib/rom/sql/projection_dsl.rb +16 -0
- data/lib/rom/sql/relation/reading.rb +18 -0
- data/lib/rom/sql/version.rb +1 -1
- data/lib/rom/sql/wrap.rb +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3c85bad1904593cc81ceecc277c2dd0bdebbe452815f366b55a016d9b4dc9e0c
|
4
|
+
data.tar.gz: 716ab6775db7fbcb1e7cf4fe88d109a8a9ee0c66ed905b6cb07a26926ee11c0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc1ab0de6e3a30be1d42b0c6abf8e162cefdbf7a8a9bf00eda79689c85b44353cb8b2a30b016f4f0b37ea75206677f67ec1a60833afc344ba898e6ee7fd5e7d
|
7
|
+
data.tar.gz: fbbd991e67b153dd2899159eb4c3ea6f1aae0682f0496bc1955c368479b78956e15076d41b2a96803791457f01b4ad2b0ed9fdf3161278456cb8386d83b9eb8f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## v2.4.0 2018-02-18
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
* Support for functions with `Any` return type (GustavoCaso)
|
6
|
+
* New `Relation#as_hash` method (GustavoCaso)
|
7
|
+
|
8
|
+
[Compare v2.3.0...v2.4.0](https://github.com/rom-rb/rom-sql/compare/v2.3.0...v2.4.0)
|
9
|
+
|
1
10
|
## v2.3.0 2017-11-17
|
2
11
|
|
3
12
|
### Added
|
@@ -62,7 +62,7 @@ module ROM
|
|
62
62
|
|
63
63
|
# Upsert command
|
64
64
|
#
|
65
|
-
# The command
|
65
|
+
# The command being called attempts to insert a record and
|
66
66
|
# if the inserted row would violate a unique constraint
|
67
67
|
# updates the conflicting row (or silently does nothing).
|
68
68
|
# A very important implementation detail is that the whole operation
|
@@ -23,6 +23,22 @@ module ROM
|
|
23
23
|
::ROM::SQL::Attribute.new(type(:string)).meta(sql_expr: expr)
|
24
24
|
end
|
25
25
|
|
26
|
+
# Return a SQL function with value `Any`
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# users.select { function(:count, :id).as(:total) }
|
30
|
+
#
|
31
|
+
# @param [Symbol] name SQL function
|
32
|
+
# @param [Symbol] attr
|
33
|
+
#
|
34
|
+
# @return [Rom::SQL::Function]
|
35
|
+
#
|
36
|
+
# @api public
|
37
|
+
def function(name, attr)
|
38
|
+
::ROM::SQL::Function.new(::ROM::Types::Any, schema: schema).public_send(name, attr)
|
39
|
+
end
|
40
|
+
alias_method :f, :function
|
41
|
+
|
26
42
|
# @api private
|
27
43
|
def respond_to_missing?(name, include_private = false)
|
28
44
|
super || type(name)
|
@@ -919,6 +919,24 @@ module ROM
|
|
919
919
|
end
|
920
920
|
end
|
921
921
|
|
922
|
+
# Returns hash with all tuples being
|
923
|
+
# the key of each the provided attribute
|
924
|
+
#
|
925
|
+
# @example default use primary_key
|
926
|
+
# users.as_hash
|
927
|
+
# # {1 => {id: 1, name: 'Jane'}}
|
928
|
+
#
|
929
|
+
# @example using other attribute
|
930
|
+
# users.as_hash(:name)
|
931
|
+
# # {'Jane' => {id: 1, name: 'Jane'}}
|
932
|
+
#
|
933
|
+
# @return [Hash]
|
934
|
+
#
|
935
|
+
# @api public
|
936
|
+
def as_hash(attribute = primary_key)
|
937
|
+
dataset.as_hash(attribute)
|
938
|
+
end
|
939
|
+
|
922
940
|
private
|
923
941
|
|
924
942
|
# Build a locking clause
|
data/lib/rom/sql/version.rb
CHANGED
data/lib/rom/sql/wrap.rb
CHANGED
@@ -5,9 +5,10 @@ module ROM
|
|
5
5
|
# Specialized wrap relation for SQL
|
6
6
|
#
|
7
7
|
# This type of relations is returned when using `Relation#wrap` and it uses
|
8
|
-
# a join, unlike `Relation#combine
|
9
|
-
# only to tuples which have associated
|
10
|
-
# where you want to rely on this
|
8
|
+
# a join, unlike `Relation#combine` which makes separate queries. This
|
9
|
+
# means a relation is restricted only to tuples which have associated
|
10
|
+
# tuples, so it should be used in cases where you want to rely on this
|
11
|
+
# restriction.
|
11
12
|
#
|
12
13
|
# @api public
|
13
14
|
class Wrap < Relation::Wrap
|
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: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
241
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.7.4
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: SQL databases support for ROM
|