inquery 1.0.1 → 1.0.6

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: 2510806e3068638779cf5e1012b37c8ddfd1141e
4
- data.tar.gz: 60217fc4f8376d9939ba8851705a94ead50f5b22
2
+ SHA256:
3
+ metadata.gz: 7ac604691796b01bc6b7021873a6394c3080b7616b8536cc791a77e5a712b6b8
4
+ data.tar.gz: 4379bf6bd66d8f0320a0f68bd5992c69dbf6945e1fb1a3f010222dabd5cccead
5
5
  SHA512:
6
- metadata.gz: 77725cde076b84538c4a020b66e1a70a4138f3b3eed00be69f3361c1c11db1bc743794bf2f84300ff392a0c54b5799701a2f80dc2e9c19cbd16bd12e5750248a
7
- data.tar.gz: d257e5b56c8649bb77fce41b03b336a5e3506957103df9da7880d5e4d34d36ec63668cc42a6d504dfad5e4d08d16fbc9a50a6302389cc7b2eb65b089f4e25003
6
+ metadata.gz: c1ea9cb3876faf797b5e63479a24d8f8254d0f7d511f25542e8787c1577dcc1166e569add18a9cedf52a3c4d70edca85094b6972971f1f9cfcfc3215866311eb
7
+ data.tar.gz: c1c623510562c7c2dc9f41edd90a46df560ae59221a3db9317aa9d0dc5b8955b1f034b43ec14008721d8b8d51effb63d923c30ad53990d7526b8774015edacc5
@@ -0,0 +1,34 @@
1
+ # Change log
2
+
3
+ ## 1.0.5 (2020-11-24)
4
+
5
+ - Improve support for schemacop 3.x
6
+
7
+ ## 1.0.5 (2020-11-24)
8
+
9
+ - Improve support for schemacop 3.x and document it
10
+
11
+ ## 1.0.4 (2020-11-24)
12
+
13
+ - Add support for schemacop 3.x (but still using 2.x schema version)
14
+
15
+ ## 1.0.3 (2020-05-12)
16
+
17
+ - Overwrite parameter hash with the casted version if using
18
+ casting inside the schemacop `schema` block
19
+
20
+ ## 1.0.2 (2019-10-09)
21
+
22
+ - Add new mixin `RawSqlUtils`, which provides two methods for
23
+ `Inquery::Query`:
24
+
25
+ - `san`: Sanitizes SQL and performs parameter substitution
26
+ - `exec_query`: For directly executing SQL queries
27
+
28
+ ## 1.0.1 (2017-05-17)
29
+
30
+ - Pin `schemacop` version properly
31
+
32
+ ## 1.0.0 (2017-05-16)
33
+
34
+ - 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.0'
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.1
1
+ 1.0.6
@@ -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 Wed May 17 12:30:38 2017 by
112
+ Generated on Wed Nov 25 14:04:11 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 Wed May 17 12:30:38 2017 by
108
+ Generated on Wed Nov 25 14:04:12 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 Wed May 17 12:30:38 2017 by
121
+ Generated on Wed Nov 25 14:04:12 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 Wed May 17 12:30:38 2017 by
125
+ Generated on Wed Nov 25 14:04:12 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 Wed May 17 12:30:38 2017 by
125
+ Generated on Wed Nov 25 14:04:12 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 Wed May 17 12:30:38 2017 by
110
+ Generated on Wed Nov 25 14:04:12 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 14:04:12 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>