sqlstmt 0.2.1 → 0.2.2
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/sqlstmt/sqlstmt.rb +19 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b144b236ba23d79ce8976b26ef2b97e6606b380c
|
4
|
+
data.tar.gz: 8aa6ab17ea45dbb8955644f8cc643cb1bac9ac81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce0433a3f12680d3873654c25d5c5e4347a9a329e54ba906ac4fa69de3304791bd0b6237e824b56b5ca82aa601551028417b153f293e687e582efe71b94818e
|
7
|
+
data.tar.gz: fcaa33fcdb9e95c3f167a9823e094c7ef8516e11fd0841efd741e183298dd07d1d57fcdb8d918bac576971aecfcb2ca5e2ad9ff9b16714464e4c27b06f7a314a
|
data/lib/sqlstmt/sqlstmt.rb
CHANGED
@@ -24,6 +24,8 @@ class SqlStmt
|
|
24
24
|
@replace = nil
|
25
25
|
@ignore = ''
|
26
26
|
@outfile = ''
|
27
|
+
# track this explicitly to guarantee get is not used with non-select statements
|
28
|
+
@called_get = false
|
27
29
|
end
|
28
30
|
|
29
31
|
def initialize_copy(orig)
|
@@ -96,6 +98,7 @@ class SqlStmt
|
|
96
98
|
|
97
99
|
def get(*exprs)
|
98
100
|
@fields.concat(exprs)
|
101
|
+
@called_get = true
|
99
102
|
return self
|
100
103
|
end
|
101
104
|
|
@@ -223,7 +226,8 @@ private
|
|
223
226
|
def verify_minimum_requirements
|
224
227
|
if !@stmt_type
|
225
228
|
raise SqlStmtError, "unable to build sql - must call :select, :update, :insert or :delete to specify statement type"
|
226
|
-
|
229
|
+
end
|
230
|
+
if @tables.empty?
|
227
231
|
raise SqlStmtError, "unable to build sql - must call :table"
|
228
232
|
end
|
229
233
|
|
@@ -235,12 +239,22 @@ private
|
|
235
239
|
|
236
240
|
if @stmt_type == 'select'
|
237
241
|
raise SqlStmtError, "unable to build sql - must call :get" if @fields.empty?
|
238
|
-
|
242
|
+
raise SqlStmtError, "unable to build sql - must not call :set" if !@values.empty?
|
243
|
+
else
|
244
|
+
raise SqlStmtError, "unable to build sql - must not call :get" if @called_get
|
245
|
+
end
|
246
|
+
|
247
|
+
if ['update','insert'].include?(@stmt_type)
|
239
248
|
raise SqlStmtError, "unable to build sql - must call :set or :setq" if @fields.empty?
|
240
|
-
|
249
|
+
raise SqlStmtError, "unable to build sql - must not call :get" if @called_get
|
250
|
+
end
|
251
|
+
|
252
|
+
if @stmt_type == 'insert'
|
241
253
|
raise SqlStmtError, "unable to build sql - must call :into" if @into_table.nil?
|
242
|
-
|
243
|
-
|
254
|
+
end
|
255
|
+
|
256
|
+
if @stmt_type == 'delete'
|
257
|
+
raise SqlStmtError, "unable to build sql - must not call :get or :set" if !@fields.empty?
|
244
258
|
if @tables_to_delete.empty? && ((@tables.size + @joins.size) > 1)
|
245
259
|
raise SqlStmtError, "unable to build sql - must specify tables to delete when including multiple tables"
|
246
260
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlstmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makani Mason
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: build SQL statements in a modular fashion, one piece at a time; only
|
15
15
|
used/tested with MySQL so far
|