occams-record 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/occams-record/binds_converter/named.rb +11 -22
- data/lib/occams-record/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e051033114483887f29a642acfd83c92907d10f15ebac551cbbb61bcc73bf3
|
4
|
+
data.tar.gz: b14f0462cdf4b04c3264f40e9bad8ec11042f23abad2fa0933b16ea02ff03d44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ccd9b91278ba7e95ba178ae786e17721d058c5f433b1594982fcd8e9e3c75c304d3bbe6a28f80ca543c71e53a0c053503f200a82083f2fe7d20e4072c99b86b
|
7
|
+
data.tar.gz: 575e5804b5d6a14f8f02c3afa1309310111a93bf77788d10b5e67d24bc67a88b072e9a2f9c25b31715a96bb47098066b47bbb5d9fceaf4c4da7cf0b0d4d2fc76
|
data/README.md
CHANGED
@@ -8,6 +8,8 @@ Learn OccamsRecord by reading [The Book at occams.jordanhollinger.com](https://o
|
|
8
8
|
|
9
9
|
API documentation is available at [rubydoc.info/gems/occams-record](http://www.rubydoc.info/gems/occams-record).
|
10
10
|
|
11
|
+
*Want OccamsRecord's flexible preloading in ActiveRecord itself? Check out [Uberloader](https://github.com/jhollinger/uberloader/)!*
|
12
|
+
|
11
13
|
OccamsRecord is a high-efficiency, advanced query library for use alongside ActiveRecord. It is **not** an ORM or an ActiveRecord replacement. OccamsRecord can breathe fresh life into your ActiveRecord app by giving it two things:
|
12
14
|
|
13
15
|
### 1) Huge performance gains
|
@@ -1,33 +1,22 @@
|
|
1
1
|
module OccamsRecord
|
2
2
|
module BindsConverter
|
3
|
-
# @private
|
4
|
-
WORD = /\w/
|
5
|
-
|
6
3
|
#
|
7
4
|
# Converts Rails-style named binds (:foo) into native Ruby format (%{foo}).
|
8
5
|
#
|
9
|
-
class Named
|
6
|
+
class Named
|
10
7
|
def initialize(sql)
|
11
|
-
|
8
|
+
@sql = sql
|
12
9
|
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
if @i > @start_i
|
26
|
-
name = @sql[@start_i..@i - 1]
|
27
|
-
@start_i = @i
|
28
|
-
"%{#{name}}"
|
29
|
-
else
|
30
|
-
@sql[old_i]
|
11
|
+
def to_s
|
12
|
+
@sql.gsub(/([:\\]?):([a-zA-Z]\w*)/) do |match|
|
13
|
+
if $1 == ":".freeze # skip PostgreSQL casts
|
14
|
+
match # return the whole match
|
15
|
+
elsif $1 == "\\".freeze # escaped literal colon
|
16
|
+
match[1..-1] # return match with escaping backslash char removed
|
17
|
+
else
|
18
|
+
"%{#{$2}}"
|
19
|
+
end
|
31
20
|
end
|
32
21
|
end
|
33
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occams-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '6.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.3'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '6.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.3'
|
33
33
|
description: A faster, lower-memory, fuller-featured querying API for ActiveRecord
|
34
34
|
that returns results as unadorned, read-only objects.
|
35
35
|
email: jordan.hollinger@gmail.com
|