db2_query 0.1.0 → 0.2.0

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.
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Db2Query
4
- module SQLValidator
5
- DEFAULT_TASK_COMMANDS = [:create, :drop, :delete, :insert, :set, :update]
6
- COMMENT_REGEX = %r{/\*(?:[^\*]|\*[^/])*\*/}m
7
-
8
- def task_command?(sql_statement)
9
- sql_statement.match?(task_commands_regexp)
10
- end
11
-
12
- def query_command?(sql_statement)
13
- sql_statement.match?(/select/i)
14
- end
15
-
16
- def is_query?(sql_statement)
17
- query_command?(sql_statement) && !task_command?(sql_statement)
18
- end
19
-
20
- private
21
- def task_commands_regexp
22
- parts = DEFAULT_TASK_COMMANDS.map { |part| /#{part}/i }
23
- /\A(?:[\(\s]|#{COMMENT_REGEX})*#{Regexp.union(*parts)}/i
24
- end
25
- end
26
- end