db2_query 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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