sqlstmt 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sqlstmt/sqlstmt.rb +15 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9ad2f845f1232665d90055dce82ff06cee0339
|
4
|
+
data.tar.gz: 23b36babca7556403e80a85f64d87117bd0afc39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a411a366d8aad05c009a1dbdd8adb436d96f2f368be14e7f6169e54ff13121f4e15e689295602093ce30b19721a4de8355adbf0b7bca93c61b9e1bdbf4c1015f
|
7
|
+
data.tar.gz: c1fdf90de136162338a5f2ba580adc40d62d1b1f7acbf1466f09fd9931e6e702da84f4552865ca210a0c516869afcbb96de194a579670261fb7674a1d655bba7
|
data/lib/sqlstmt/sqlstmt.rb
CHANGED
@@ -222,40 +222,28 @@ private
|
|
222
222
|
|
223
223
|
def verify_minimum_requirements
|
224
224
|
if !@stmt_type
|
225
|
-
raise SqlStmtError, "unable to build sql - must specify statement type"
|
226
|
-
elsif
|
225
|
+
raise SqlStmtError, "unable to build sql - must call :select, :update, :insert or :delete to specify statement type"
|
226
|
+
elsif @tables.empty?
|
227
|
+
raise SqlStmtError, "unable to build sql - must call :table"
|
228
|
+
end
|
229
|
+
|
230
|
+
if (@where_behavior == :require) && @wheres.empty?
|
227
231
|
raise SqlStmtError, "unable to build sql - must call :where, :no_where, or :optional_where"
|
228
232
|
elsif (@where_behavior == :exclude) && !@wheres.empty?
|
229
233
|
raise SqlStmtError, "unable to build sql - :where and :no_where must not both be called, consider :optional_where instead"
|
230
234
|
end
|
231
235
|
|
232
|
-
if ['select','insert','delete'].include?(@stmt_type)
|
233
|
-
raise SqlStmtError, "unable to build sql - must call :table or :join (or one if it's variants)" if @tables.empty? && @joins.empty?
|
234
|
-
raise SqlStmtError, "unable to build sql - must call :table if using :join (or one if it's variants)" if @tables.empty? && !@joins.empty?
|
235
|
-
end
|
236
|
-
|
237
236
|
if @stmt_type == 'select'
|
238
|
-
raise SqlStmtError, "unable to build sql - must call :
|
239
|
-
|
240
|
-
|
241
|
-
|
237
|
+
raise SqlStmtError, "unable to build sql - must call :get" if @fields.empty?
|
238
|
+
elsif @stmt_type == 'update'
|
239
|
+
raise SqlStmtError, "unable to build sql - must call :set or :setq" if @fields.empty?
|
240
|
+
elsif @stmt_type == 'insert'
|
242
241
|
raise SqlStmtError, "unable to build sql - must call :into" if @into_table.nil?
|
243
|
-
raise SqlStmtError, "unable to build sql - must call :
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
raise SqlStmtError, "unable to build sql - must call :field or :fieldq" if @fields.empty?
|
249
|
-
end
|
250
|
-
|
251
|
-
if @stmt_type == 'update'
|
252
|
-
raise SqlStmtError, "unable to build sql - must call :table" if @tables.empty?
|
253
|
-
raise SqlStmtError, "unable to build sql - must call :field or :fieldq" if @fields.empty?
|
254
|
-
end
|
255
|
-
|
256
|
-
if @stmt_type == 'delete'
|
257
|
-
combined_table_count = @tables.size + @joins.size
|
258
|
-
raise SqlStmtError, "unable to build sql - must call :from when including multiple tables" if @tables_to_delete.empty? && (combined_table_count > 1)
|
242
|
+
raise SqlStmtError, "unable to build sql - must call :set or :setq" if @fields.empty?
|
243
|
+
elsif @stmt_type == 'delete'
|
244
|
+
if @tables_to_delete.empty? && ((@tables.size + @joins.size) > 1)
|
245
|
+
raise SqlStmtError, "unable to build sql - must specify tables to delete when including multiple tables"
|
246
|
+
end
|
259
247
|
end
|
260
248
|
end
|
261
249
|
|