inquery 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 384b003981408ccd6f8f1f87d12e7d8e0a7b08fa
4
- data.tar.gz: d4b1decccb8a2c9244988bcac72ba58d98f04683
2
+ SHA256:
3
+ metadata.gz: b9f801dda19001820dd1c718274b186db13f298cecbe63f7062aafa630f0e1e5
4
+ data.tar.gz: 58a918e65d1dea35052817e4014fa80669d5dd96d0add4b273861d8b5ea2637a
5
5
  SHA512:
6
- metadata.gz: a23c59f39af04e1792414d61fb9ed522c4279a35e57ade91f70bc2bdc1afb9d3b1775a978f3d96fd1b90b471769213277abd0e0ee3e0b3fb2ec31a1ba20184f6
7
- data.tar.gz: ca4b8f8c2c14966d2a8741c020cf1e575da31de43bb5796313f72ea89c0d00344626a588db20a48e7046c3649d0e6678abd11e85e42c133baf3bf51d58c1ae36
6
+ metadata.gz: 35b838d2d208690d92cc510c833fe8c7561c8d383b73afde4916990e8f109fe52e37ed239b48461174fc6cc9c417c9a63d5a0fed3ed39e9f594079862439596e
7
+ data.tar.gz: 8ac2f807c4c271a12f8fe77892c97d7b0ace085d33c8f174a0c96e23451dfa910044081a511d8593fc6815ba81202a1107ee77480224d8e67dd3f8b2f150b14c
@@ -0,0 +1,30 @@
1
+ # Change log
2
+
3
+ ## 1.0.5 (2020-11-23)
4
+
5
+ - Improve support for schemacop 3.x and document it
6
+
7
+ ## 1.0.4 (2020-11-24)
8
+
9
+ - Add support for schemacop 3.x (but still using 2.x schema version)
10
+
11
+ ## 1.0.3 (2020-05-12)
12
+
13
+ - Overwrite parameter hash with the casted version if using
14
+ casting inside the schemacop `schema` block
15
+
16
+ ## 1.0.2 (2019-10-09)
17
+
18
+ - Add new mixin `RawSqlUtils`, which provides two methods for
19
+ `Inquery::Query`:
20
+
21
+ - `san`: Sanitizes SQL and performs parameter substitution
22
+ - `exec_query`: For directly executing SQL queries
23
+
24
+ ## 1.0.1 (2017-05-17)
25
+
26
+ - Pin `schemacop` version properly
27
+
28
+ ## 1.0.0 (2017-05-16)
29
+
30
+ - Initial release
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2016 Sitrox
3
+ Copyright (c) 2020 Sitrox
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -87,6 +87,37 @@ FetchRedCarsAsJson.new(params = {}).call
87
87
  Note that it's perfectly fine for some queries to return `nil`, i.e. if they're
88
88
  writing queries that don't fetch any results.
89
89
 
90
+ ### Using raw SQL
91
+
92
+ In some cases it may make sense to push down all computation to the database and
93
+ only construct an SQL query for this purpose. To facilitate this,
94
+ {Inquery::Query} provides sanitization and query execution methods:
95
+
96
+ ```ruby
97
+ # Note: There are better ways of achieving the same result, this is an example
98
+ # to demonstrate the methods.
99
+ class CheckIfSold < Inquery::Query
100
+ def call
101
+ parts = [
102
+ 'SELECT car_id FROM dealership_sales',
103
+ 'SELECT car_id FROM dealership_leasings'
104
+ ]
105
+
106
+ sql = 'SELECT ? IN (' + parts.join(' UNION ') + ')'
107
+
108
+ # The 'san' method takes n+1 arguments: The SQL string and n parameters
109
+ sanitized_sql = san(sql, osparams.car_id)
110
+
111
+ # Returns instance of ActiveRecord::Result
112
+ return exec_query(sanitized_sql)
113
+ end
114
+
115
+ def process(results)
116
+ results.rows.first.first
117
+ end
118
+ end
119
+ ```
120
+
90
121
  ## Chainable queries
91
122
 
92
123
  Chainable queries are queries that input and output an Active Record relation.
@@ -253,6 +284,9 @@ class SomeQueryClass < Inquery::Query
253
284
  end
254
285
  ```
255
286
 
287
+ Inquery supports both schemacop specification versions 2 and 3 using the methods
288
+ `schema` / `schema2` for version 2 and method `schema3` for version 3.
289
+
256
290
  ## Rails integration
257
291
 
258
292
  While it is optional, Inquery has been written from the ground up to be
@@ -288,8 +322,7 @@ There are some key benefits to this approach:
288
322
 
289
323
  Thanks to Jeroen Weeink for his insights regarding using query classes as scopes
290
324
  in his [blog post](http://craftingruby.com/posts/2015/06/29/query-objects-through-scopes.html).
291
- And special thanks to [SubGit](http://www.subgit.com/) for their great open source licensing.
292
325
 
293
326
  ## Copyright
294
327
 
295
- Copyright (c) 2017 Sitrox. See `LICENSE` for further details.
328
+ Copyright (c) 2020 Sitrox. See `LICENSE` for further details.
@@ -1 +1 @@
1
- ruby-2.3.1-p112
1
+ ruby-2.6.2-p47
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ task :gemspec do
11
11
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
12
12
  spec.require_paths = ['lib']
13
13
 
14
- spec.add_development_dependency 'bundler', '~> 1.3'
14
+ spec.add_development_dependency 'bundler'
15
15
  spec.add_development_dependency 'rake'
16
16
  spec.add_development_dependency 'sqlite3'
17
17
  spec.add_development_dependency 'haml'
@@ -21,7 +21,7 @@ task :gemspec do
21
21
  spec.add_dependency 'minitest'
22
22
  spec.add_dependency 'activesupport'
23
23
  spec.add_dependency 'activerecord'
24
- spec.add_dependency 'schemacop', '~> 2'
24
+ spec.add_dependency 'schemacop', '>= 2.0'
25
25
  end
26
26
 
27
27
  File.open('inquery.gemspec', 'w') { |f| f.write(gemspec.to_ruby.strip) }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.5
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Module: Inquery
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery";
19
19
  relpath = '';
20
20
  </script>
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
81
  <dd>lib/inquery.rb<span class="defines">,<br />
82
- lib/inquery/query.rb,<br /> lib/inquery/exceptions.rb,<br /> lib/inquery/query/chainable.rb,<br /> lib/inquery/mixins/schema_validation.rb,<br /> lib/inquery/mixins/relation_validation.rb</span>
82
+ lib/inquery/query.rb,<br /> lib/inquery/exceptions.rb,<br /> lib/inquery/query/chainable.rb,<br /> lib/inquery/mixins/raw_sql_utils.rb,<br /> lib/inquery/mixins/schema_validation.rb,<br /> lib/inquery/mixins/relation_validation.rb</span>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -109,9 +109,9 @@
109
109
  </div>
110
110
 
111
111
  <div id="footer">
112
- Generated on Tue May 16 13:42:30 2017 by
112
+ Generated on Wed Nov 25 13:57:22 2020 by
113
113
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
114
- 0.9.9 (ruby-2.3.1).
114
+ 0.9.25 (ruby-2.6.2).
115
115
  </div>
116
116
 
117
117
  </div>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Module: Inquery::Exceptions
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery::Exceptions";
19
19
  relpath = '../';
20
20
  </script>
@@ -105,9 +105,9 @@
105
105
  </div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Tue May 16 13:42:30 2017 by
108
+ Generated on Wed Nov 25 13:57:22 2020 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
- 0.9.9 (ruby-2.3.1).
110
+ 0.9.25 (ruby-2.6.2).
111
111
  </div>
112
112
 
113
113
  </div>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Exception: Inquery::Exceptions::Base
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery::Exceptions::Base";
19
19
  relpath = '../../';
20
20
  </script>
@@ -118,9 +118,9 @@
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Tue May 16 13:42:30 2017 by
121
+ Generated on Wed Nov 25 13:57:22 2020 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
- 0.9.9 (ruby-2.3.1).
123
+ 0.9.25 (ruby-2.6.2).
124
124
  </div>
125
125
 
126
126
  </div>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Exception: Inquery::Exceptions::InvalidRelation
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery::Exceptions::InvalidRelation";
19
19
  relpath = '../../';
20
20
  </script>
@@ -122,9 +122,9 @@
122
122
  </div>
123
123
 
124
124
  <div id="footer">
125
- Generated on Tue May 16 13:42:30 2017 by
125
+ Generated on Wed Nov 25 13:57:22 2020 by
126
126
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
- 0.9.9 (ruby-2.3.1).
127
+ 0.9.25 (ruby-2.6.2).
128
128
  </div>
129
129
 
130
130
  </div>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Exception: Inquery::Exceptions::UnknownCallSignature
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery::Exceptions::UnknownCallSignature";
19
19
  relpath = '../../';
20
20
  </script>
@@ -122,9 +122,9 @@
122
122
  </div>
123
123
 
124
124
  <div id="footer">
125
- Generated on Tue May 16 13:42:30 2017 by
125
+ Generated on Wed Nov 25 13:57:22 2020 by
126
126
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
- 0.9.9 (ruby-2.3.1).
127
+ 0.9.25 (ruby-2.6.2).
128
128
  </div>
129
129
 
130
130
  </div>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Module: Inquery::Mixins
8
8
 
9
- &mdash; Documentation by YARD 0.9.9
9
+ &mdash; Documentation by YARD 0.9.25
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "Inquery::Mixins";
19
19
  relpath = '../';
20
20
  </script>
@@ -78,8 +78,8 @@
78
78
 
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
- <dd>lib/inquery/mixins/schema_validation.rb<span class="defines">,<br />
82
- lib/inquery/mixins/relation_validation.rb</span>
81
+ <dd>lib/inquery/mixins/raw_sql_utils.rb<span class="defines">,<br />
82
+ lib/inquery/mixins/schema_validation.rb,<br /> lib/inquery/mixins/relation_validation.rb</span>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -89,7 +89,7 @@
89
89
  <p class="children">
90
90
 
91
91
 
92
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mixins/RelationValidation.html" title="Inquery::Mixins::RelationValidation (module)">RelationValidation</a></span>, <span class='object_link'><a href="Mixins/SchemaValidation.html" title="Inquery::Mixins::SchemaValidation (module)">SchemaValidation</a></span>
92
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mixins/RawSqlUtils.html" title="Inquery::Mixins::RawSqlUtils (module)">RawSqlUtils</a></span>, <span class='object_link'><a href="Mixins/RelationValidation.html" title="Inquery::Mixins::RelationValidation (module)">RelationValidation</a></span>, <span class='object_link'><a href="Mixins/SchemaValidation.html" title="Inquery::Mixins::SchemaValidation (module)">SchemaValidation</a></span>
93
93
 
94
94
 
95
95
 
@@ -107,9 +107,9 @@
107
107
  </div>
108
108
 
109
109
  <div id="footer">
110
- Generated on Tue May 16 13:42:30 2017 by
110
+ Generated on Wed Nov 25 13:57:22 2020 by
111
111
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
112
- 0.9.9 (ruby-2.3.1).
112
+ 0.9.25 (ruby-2.6.2).
113
113
  </div>
114
114
 
115
115
  </div>
@@ -0,0 +1,116 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Inquery::Mixins::RawSqlUtils
8
+
9
+ &mdash; Documentation by YARD 0.9.25
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Inquery::Mixins::RawSqlUtils";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (R)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Inquery.html" title="Inquery (module)">Inquery</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Mixins.html" title="Inquery::Mixins (module)">Mixins</a></span></span>
41
+ &raquo;
42
+ <span class="title">RawSqlUtils</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Inquery::Mixins::RawSqlUtils
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+ <dl>
73
+ <dt>Extended by:</dt>
74
+ <dd>ActiveSupport::Concern</dd>
75
+ </dl>
76
+
77
+
78
+
79
+
80
+
81
+
82
+ <dl>
83
+ <dt>Included in:</dt>
84
+ <dd><span class='object_link'><a href="../Query.html" title="Inquery::Query (class)">Query</a></span></dd>
85
+ </dl>
86
+
87
+
88
+
89
+ <dl>
90
+ <dt>Defined in:</dt>
91
+ <dd>lib/inquery/mixins/raw_sql_utils.rb</dd>
92
+ </dl>
93
+
94
+ </div>
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ </div>
107
+
108
+ <div id="footer">
109
+ Generated on Wed Nov 25 13:57:22 2020 by
110
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
111
+ 0.9.25 (ruby-2.6.2).
112
+ </div>
113
+
114
+ </div>
115
+ </body>
116
+ </html>