sqlstmt 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sqlstmt/sqlstmt.rb +15 -27
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b7746931f2110ac0ed453789e2374c05b4233ee
4
- data.tar.gz: 46c5f8f2a3baa4023d08541c47eb7f45a7fd9cb1
3
+ metadata.gz: be9ad2f845f1232665d90055dce82ff06cee0339
4
+ data.tar.gz: 23b36babca7556403e80a85f64d87117bd0afc39
5
5
  SHA512:
6
- metadata.gz: 0d5a0ad3df986f73d4729334bab6353b3b77372f1bb78d65f2a5ff5ae626cc5a3a616f5be7ebe32887ea059da6452dbd5e8c1c9a9cf37a71df88ac77f5b9a08d
7
- data.tar.gz: 840fdd50d95167f638d5fbb78e5fedeb72d42910a45781b3a50af50feb968121b790d9c7a954de653ee3d408deda9782cd18ac49e80d5fef1659dce94082dfbe
6
+ metadata.gz: a411a366d8aad05c009a1dbdd8adb436d96f2f368be14e7f6169e54ff13121f4e15e689295602093ce30b19721a4de8355adbf0b7bca93c61b9e1bdbf4c1015f
7
+ data.tar.gz: c1fdf90de136162338a5f2ba580adc40d62d1b1f7acbf1466f09fd9931e6e702da84f4552865ca210a0c516869afcbb96de194a579670261fb7674a1d655bba7
@@ -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 (@where_behavior == :require) && @wheres.empty?
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 :field" if @fields.empty?
239
- end
240
-
241
- if @stmt_type == 'insert_values'
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 :field or :fieldq" if @fields.empty?
244
- end
245
-
246
- if @stmt_type == 'insert_select'
247
- raise SqlStmtError, "unable to build sql - must call :into" if @into_table.nil?
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
 
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makani Mason