ronin-sql 0.2.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +623 -288
- data/{History.txt → ChangeLog.md} +33 -35
- data/Gemfile +25 -0
- data/README.md +110 -0
- data/Rakefile +30 -20
- data/bin/ronin-sql +18 -5
- data/gemspec.yml +16 -0
- data/lib/ronin/formatting/extensions/sql.rb +4 -3
- data/lib/ronin/formatting/extensions/sql/string.rb +83 -10
- data/lib/ronin/formatting/sql.rb +4 -3
- data/lib/ronin/sql.rb +5 -12
- data/lib/ronin/{code/sql/create_index.rb → sql/binary_expr.rb} +25 -18
- data/lib/ronin/sql/clause.rb +72 -0
- data/lib/ronin/sql/clauses.rb +297 -0
- data/lib/ronin/sql/emittable.rb +84 -0
- data/lib/ronin/sql/emitter.rb +375 -0
- data/lib/ronin/sql/field.rb +106 -0
- data/lib/ronin/{code/sql/as.rb → sql/fields.rb} +36 -17
- data/lib/ronin/{code/sql/binary_expr.rb → sql/function.rb} +27 -27
- data/lib/ronin/sql/functions.rb +989 -0
- data/lib/ronin/sql/injection.rb +125 -157
- data/lib/ronin/{code/sql/default_values_clause.rb → sql/literal.rb} +13 -11
- data/lib/ronin/sql/literals.rb +72 -0
- data/lib/ronin/sql/operators.rb +332 -0
- data/lib/ronin/sql/sql.rb +86 -0
- data/lib/ronin/sql/statement.rb +70 -0
- data/lib/ronin/sql/statement_list.rb +110 -0
- data/lib/ronin/sql/statements.rb +115 -0
- data/lib/ronin/{code/sql/desc.rb → sql/unary_expr.rb} +11 -11
- data/lib/ronin/sql/version.rb +5 -4
- data/ronin-sql.gemspec +61 -0
- data/spec/formatting/sql/string_spec.rb +172 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/sql/binary_expr.rb +5 -0
- data/spec/sql/binary_expr_examples.rb +25 -0
- data/spec/sql/clause_examples.rb +43 -0
- data/spec/sql/clause_spec.rb +31 -0
- data/spec/sql/clauses_spec.rb +43 -0
- data/spec/sql/emittable_spec.rb +41 -0
- data/spec/sql/emitter_spec.rb +472 -0
- data/spec/sql/field_spec.rb +103 -0
- data/spec/sql/fields_spec.rb +40 -0
- data/spec/sql/function_examples.rb +30 -0
- data/spec/sql/function_spec.rb +25 -0
- data/spec/sql/functions_spec.rb +110 -0
- data/spec/sql/injection_spec.rb +233 -0
- data/spec/sql/literal_spec.rb +5 -0
- data/spec/sql/literals_spec.rb +46 -0
- data/spec/sql/operators_spec.rb +44 -0
- data/spec/sql/sql_spec.rb +18 -0
- data/spec/sql/statement_examples.rb +39 -0
- data/spec/sql/statement_list_spec.rb +48 -0
- data/spec/sql/statement_sql.rb +38 -0
- data/spec/sql/statements_spec.rb +22 -0
- data/spec/sql/unary_expr.rb +5 -0
- data/spec/sql/unary_expr_examples.rb +20 -0
- metadata +116 -217
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -108
- data/README.txt +0 -112
- data/lib/ronin/code/sql.rb +0 -22
- data/lib/ronin/code/sql/add_column_clause.rb +0 -42
- data/lib/ronin/code/sql/alter_table.rb +0 -52
- data/lib/ronin/code/sql/asc.rb +0 -36
- data/lib/ronin/code/sql/between.rb +0 -66
- data/lib/ronin/code/sql/clause.rb +0 -35
- data/lib/ronin/code/sql/code.rb +0 -35
- data/lib/ronin/code/sql/common_dialect.rb +0 -66
- data/lib/ronin/code/sql/create.rb +0 -74
- data/lib/ronin/code/sql/create_table.rb +0 -44
- data/lib/ronin/code/sql/create_view.rb +0 -41
- data/lib/ronin/code/sql/delete.rb +0 -52
- data/lib/ronin/code/sql/dialect.rb +0 -282
- data/lib/ronin/code/sql/drop.rb +0 -55
- data/lib/ronin/code/sql/drop_index.rb +0 -41
- data/lib/ronin/code/sql/drop_table.rb +0 -41
- data/lib/ronin/code/sql/drop_view.rb +0 -41
- data/lib/ronin/code/sql/emittable.rb +0 -100
- data/lib/ronin/code/sql/exceptions.rb +0 -24
- data/lib/ronin/code/sql/exceptions/unknown_clause.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_dialect.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_statement.rb +0 -29
- data/lib/ronin/code/sql/expr.rb +0 -102
- data/lib/ronin/code/sql/field.rb +0 -101
- data/lib/ronin/code/sql/fields_clause.rb +0 -46
- data/lib/ronin/code/sql/from_clause.rb +0 -42
- data/lib/ronin/code/sql/function.rb +0 -53
- data/lib/ronin/code/sql/group_by_clause.rb +0 -46
- data/lib/ronin/code/sql/having_clause.rb +0 -46
- data/lib/ronin/code/sql/in.rb +0 -47
- data/lib/ronin/code/sql/injected_statement.rb +0 -100
- data/lib/ronin/code/sql/injection.rb +0 -203
- data/lib/ronin/code/sql/insert.rb +0 -54
- data/lib/ronin/code/sql/intersect_clause.rb +0 -42
- data/lib/ronin/code/sql/join_clause.rb +0 -123
- data/lib/ronin/code/sql/like.rb +0 -73
- data/lib/ronin/code/sql/limit_clause.rb +0 -42
- data/lib/ronin/code/sql/modifier.rb +0 -48
- data/lib/ronin/code/sql/offset_clause.rb +0 -42
- data/lib/ronin/code/sql/on_clause.rb +0 -55
- data/lib/ronin/code/sql/order_by_clause.rb +0 -42
- data/lib/ronin/code/sql/program.rb +0 -225
- data/lib/ronin/code/sql/rename_to_clause.rb +0 -42
- data/lib/ronin/code/sql/replace.rb +0 -54
- data/lib/ronin/code/sql/select.rb +0 -103
- data/lib/ronin/code/sql/set_clause.rb +0 -42
- data/lib/ronin/code/sql/statement.rb +0 -180
- data/lib/ronin/code/sql/token.rb +0 -62
- data/lib/ronin/code/sql/unary_expr.rb +0 -47
- data/lib/ronin/code/sql/union_all_clause.rb +0 -42
- data/lib/ronin/code/sql/union_clause.rb +0 -42
- data/lib/ronin/code/sql/update.rb +0 -52
- data/lib/ronin/code/sql/values_clause.rb +0 -46
- data/lib/ronin/code/sql/where_clause.rb +0 -42
- data/lib/ronin/sql/error.rb +0 -26
- data/lib/ronin/sql/error/error.rb +0 -62
- data/lib/ronin/sql/error/extensions.rb +0 -22
- data/lib/ronin/sql/error/extensions/string.rb +0 -77
- data/lib/ronin/sql/error/message.rb +0 -62
- data/lib/ronin/sql/error/pattern.rb +0 -104
- data/lib/ronin/sql/error/patterns.rb +0 -99
- data/lib/ronin/sql/extensions.rb +0 -22
- data/lib/ronin/sql/extensions/uri.rb +0 -22
- data/lib/ronin/sql/extensions/uri/http.rb +0 -107
- data/spec/code/sql/common_dialect_spec.rb +0 -205
- data/spec/code/sql/create_examples.rb +0 -19
- data/spec/code/sql/create_index_spec.rb +0 -25
- data/spec/code/sql/create_table_spec.rb +0 -27
- data/spec/code/sql/create_view_spec.rb +0 -16
- data/spec/code/sql/delete_spec.rb +0 -14
- data/spec/code/sql/drop_examples.rb +0 -10
- data/spec/code/sql/drop_index_spec.rb +0 -16
- data/spec/code/sql/drop_table_spec.rb +0 -16
- data/spec/code/sql/drop_view_spec.rb +0 -16
- data/spec/code/sql/has_default_values_clause_examples.rb +0 -10
- data/spec/code/sql/has_fields_clause_examples.rb +0 -15
- data/spec/code/sql/has_from_clause_examples.rb +0 -13
- data/spec/code/sql/has_values_clause_examples.rb +0 -15
- data/spec/code/sql/has_where_clause_examples.rb +0 -15
- data/spec/code/sql/insert_spec.rb +0 -21
- data/spec/code/sql/replace_spec.rb +0 -21
- data/spec/code/sql/select_spec.rb +0 -105
- data/spec/code/sql/update_spec.rb +0 -26
- data/spec/helpers/code.rb +0 -14
- data/spec/sql/error_spec.rb +0 -24
- data/spec/sql/extensions/uri/http_spec.rb +0 -34
- data/spec/sql_spec.rb +0 -9
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -13
- metadata.gz.sig +0 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
#
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This file is part of Ronin SQL.
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/sql/operators'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module SQL
|
27
|
+
#
|
28
|
+
# Represents a SQL column, table or database name.
|
29
|
+
#
|
30
|
+
class Field < Struct.new(:name,:parent)
|
31
|
+
|
32
|
+
include Operators
|
33
|
+
|
34
|
+
#
|
35
|
+
# Initializes the new field.
|
36
|
+
#
|
37
|
+
# @param [String] name
|
38
|
+
# The name of the field.
|
39
|
+
#
|
40
|
+
# @param [Field] parent
|
41
|
+
# The parent of the field.
|
42
|
+
#
|
43
|
+
def initialize(name,parent=nil)
|
44
|
+
super(name.to_s,parent)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Parses a field.
|
49
|
+
#
|
50
|
+
# @param [String] name
|
51
|
+
#
|
52
|
+
# @return [Field]
|
53
|
+
# The parsed field.
|
54
|
+
#
|
55
|
+
def self.parse(name)
|
56
|
+
names = name.to_s.split('.',3)
|
57
|
+
field = nil
|
58
|
+
|
59
|
+
names.each { |name| field = new(name,field) }
|
60
|
+
|
61
|
+
return field
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Converts the field to a String.
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
# The full field name.
|
69
|
+
#
|
70
|
+
def to_s
|
71
|
+
if parent then "#{parent}.#{name}"
|
72
|
+
else name.to_s
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
alias to_str to_s
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
#
|
81
|
+
# Allows accessing columns from tables or tables from databases.
|
82
|
+
#
|
83
|
+
# @param [Symbol] name
|
84
|
+
# The sub-field name.
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# db.users
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# users.id
|
91
|
+
#
|
92
|
+
def method_missing(name,*arguments)
|
93
|
+
unless arguments.empty?
|
94
|
+
raise(ArgumentError,"canot access columns or tables with arguments")
|
95
|
+
end
|
96
|
+
|
97
|
+
if (self.parent.nil? || self.parent.parent.nil?)
|
98
|
+
Field.new(name,self)
|
99
|
+
else
|
100
|
+
raise(NoMethodError,"cannot access coumns from other columns")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
#
|
2
|
-
# Ronin SQL - A
|
3
|
-
# tasks.
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
4
3
|
#
|
5
|
-
# Copyright (c) 2007-
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This file is part of Ronin SQL.
|
6
7
|
#
|
7
8
|
# This program is free software; you can redistribute it and/or modify
|
8
9
|
# it under the terms of the GNU General Public License as published by
|
@@ -19,26 +20,44 @@
|
|
19
20
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
21
|
#
|
21
22
|
|
22
|
-
require 'ronin/
|
23
|
+
require 'ronin/sql/field'
|
23
24
|
|
24
25
|
module Ronin
|
25
|
-
module
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
module SQL
|
27
|
+
#
|
28
|
+
# Allows creating {Field Fields} via {#method_missing}.
|
29
|
+
#
|
30
|
+
module Fields
|
31
|
+
#
|
32
|
+
# @return [true]
|
33
|
+
#
|
34
|
+
def respond_to_missing?(name)
|
35
|
+
true
|
36
|
+
end
|
31
37
|
|
32
|
-
|
33
|
-
|
38
|
+
#
|
39
|
+
# @return [nil]
|
40
|
+
#
|
41
|
+
def to_ary
|
42
|
+
end
|
34
43
|
|
35
|
-
|
36
|
-
end
|
44
|
+
protected
|
37
45
|
|
38
|
-
|
39
|
-
|
46
|
+
#
|
47
|
+
# Allows specifying databases, tables or columns.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# db.users
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# users.id
|
54
|
+
#
|
55
|
+
def method_missing(name,*arguments,&block)
|
56
|
+
if (arguments.empty? && block.nil?)
|
57
|
+
Field.new(name)
|
58
|
+
else
|
59
|
+
super
|
40
60
|
end
|
41
|
-
|
42
61
|
end
|
43
62
|
end
|
44
63
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
#
|
2
|
-
# Ronin SQL - A
|
3
|
-
# tasks.
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
4
3
|
#
|
5
|
-
# Copyright (c) 2007-
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This file is part of Ronin SQL.
|
6
7
|
#
|
7
8
|
# This program is free software; you can redistribute it and/or modify
|
8
9
|
# it under the terms of the GNU General Public License as published by
|
@@ -19,33 +20,32 @@
|
|
19
20
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
21
|
#
|
21
22
|
|
22
|
-
require 'ronin/
|
23
|
+
require 'ronin/sql/operators'
|
24
|
+
require 'ronin/sql/emittable'
|
23
25
|
|
24
26
|
module Ronin
|
25
|
-
module
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
emit_value(@left) + emit_token(@op) + emit_value(@right)
|
46
|
-
end
|
47
|
-
|
27
|
+
module SQL
|
28
|
+
#
|
29
|
+
# Represents a SQL function call.
|
30
|
+
#
|
31
|
+
class Function < Struct.new(:name,:arguments)
|
32
|
+
|
33
|
+
include Operators
|
34
|
+
include Emittable
|
35
|
+
|
36
|
+
#
|
37
|
+
# Creates a new Function object.
|
38
|
+
#
|
39
|
+
# @param [Symbol] name
|
40
|
+
# The name of the function.
|
41
|
+
#
|
42
|
+
# @param [Array] arguments
|
43
|
+
# The arguments of the function.
|
44
|
+
#
|
45
|
+
def initialize(name,*arguments)
|
46
|
+
super(name,arguments)
|
48
47
|
end
|
48
|
+
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -0,0 +1,989 @@
|
|
1
|
+
#
|
2
|
+
# Ronin SQL - A Ruby DSL for crafting SQL Injections.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This file is part of Ronin SQL.
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/sql/function'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module SQL
|
27
|
+
#
|
28
|
+
# Methods for creating common SQL {Function Functions}.
|
29
|
+
#
|
30
|
+
module Functions
|
31
|
+
#
|
32
|
+
# @!group Aggregate Functions
|
33
|
+
#
|
34
|
+
|
35
|
+
#
|
36
|
+
# The `COUNT` function.
|
37
|
+
#
|
38
|
+
# @param [Field, Symbol] field
|
39
|
+
# The field to aggregate.
|
40
|
+
#
|
41
|
+
# @return [Function]
|
42
|
+
# The new function.
|
43
|
+
#
|
44
|
+
def count(field=:*)
|
45
|
+
Function.new(:COUNT,field)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# The `MAX` function.
|
50
|
+
#
|
51
|
+
# @param [Field, Symbol] field
|
52
|
+
# The field to aggregate.
|
53
|
+
#
|
54
|
+
# @return [Function]
|
55
|
+
# The new function.
|
56
|
+
#
|
57
|
+
def max(field)
|
58
|
+
Function.new(:MAX,field)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# The `MIN` function.
|
63
|
+
#
|
64
|
+
# @param [Field, Symbol] field
|
65
|
+
# The field to aggregate.
|
66
|
+
#
|
67
|
+
# @return [Function]
|
68
|
+
# The new function.
|
69
|
+
#
|
70
|
+
def min(field)
|
71
|
+
Function.new(:MIN,field)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# The `AVG` function.
|
76
|
+
#
|
77
|
+
# @param [Field, Symbol] field
|
78
|
+
# The field to aggregate.
|
79
|
+
#
|
80
|
+
# @return [Function]
|
81
|
+
# The new function.
|
82
|
+
#
|
83
|
+
def avg(field)
|
84
|
+
Function.new(:AVG,field)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# The `SUM` function.
|
89
|
+
#
|
90
|
+
# @param [Field, Symbol] field
|
91
|
+
# The field to aggregate.
|
92
|
+
#
|
93
|
+
# @return [Function]
|
94
|
+
# The new function.
|
95
|
+
#
|
96
|
+
def sum(field)
|
97
|
+
Function.new(:SUM,field)
|
98
|
+
end
|
99
|
+
|
100
|
+
#
|
101
|
+
# The `SQRT` function.
|
102
|
+
#
|
103
|
+
# @param [Field, Symbol] field
|
104
|
+
# The field to aggregate.
|
105
|
+
#
|
106
|
+
# @return [Function]
|
107
|
+
# The new function.
|
108
|
+
#
|
109
|
+
def sqrt(field)
|
110
|
+
Function.new(:SQRT,field)
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# The `RAND` function.
|
115
|
+
#
|
116
|
+
# @param [Field, Symbol] field
|
117
|
+
# The field to aggregate.
|
118
|
+
#
|
119
|
+
# @return [Function]
|
120
|
+
# The new function.
|
121
|
+
#
|
122
|
+
def rand(field)
|
123
|
+
Function.new(:RAND,field)
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# @!group Numeric Functions
|
128
|
+
#
|
129
|
+
|
130
|
+
#
|
131
|
+
# The `ABS` function.
|
132
|
+
#
|
133
|
+
# @return [Function]
|
134
|
+
# The new function.
|
135
|
+
#
|
136
|
+
def abs(x)
|
137
|
+
Function.new(:ABS,x)
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# The `ACOS` function.
|
142
|
+
#
|
143
|
+
# @return [Function]
|
144
|
+
# The new function.
|
145
|
+
#
|
146
|
+
def acos(x)
|
147
|
+
Function.new(:ACOS,x)
|
148
|
+
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# The `ASIN` function.
|
152
|
+
#
|
153
|
+
# @return [Function]
|
154
|
+
# The new function.
|
155
|
+
#
|
156
|
+
def asin(x)
|
157
|
+
Function.new(:ASIN,x)
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# The `ATAN` function.
|
162
|
+
#
|
163
|
+
# @return [Function]
|
164
|
+
# The new function.
|
165
|
+
#
|
166
|
+
def atan(x)
|
167
|
+
Function.new(:ATAN,x)
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# The `ATAN2` function.
|
172
|
+
#
|
173
|
+
# @return [Function]
|
174
|
+
# The new function.
|
175
|
+
#
|
176
|
+
def atan2(y,x)
|
177
|
+
Function.new(:ATAN2,y,x)
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# The `BIT_AND` function.
|
182
|
+
#
|
183
|
+
# @return [Function]
|
184
|
+
# The new function.
|
185
|
+
#
|
186
|
+
def bit_and(x)
|
187
|
+
Function.new(:BIT_AND,x)
|
188
|
+
end
|
189
|
+
|
190
|
+
#
|
191
|
+
# The `BIT_COUNT` function.
|
192
|
+
#
|
193
|
+
# @return [Function]
|
194
|
+
# The new function.
|
195
|
+
#
|
196
|
+
def bit_count(x)
|
197
|
+
Function.new(:BIT_COUNT,x)
|
198
|
+
end
|
199
|
+
|
200
|
+
#
|
201
|
+
# The `BIT_OR` function.
|
202
|
+
#
|
203
|
+
# @return [Function]
|
204
|
+
# The new function.
|
205
|
+
#
|
206
|
+
def bit_or(x)
|
207
|
+
Function.new(:BIT_OR,x)
|
208
|
+
end
|
209
|
+
|
210
|
+
#
|
211
|
+
# The `CEIL` function.
|
212
|
+
#
|
213
|
+
# @return [Function]
|
214
|
+
# The new function.
|
215
|
+
#
|
216
|
+
def ceil(x)
|
217
|
+
Function.new(:CEIL,x)
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# The `CEILING` function.
|
222
|
+
#
|
223
|
+
# @return [Function]
|
224
|
+
# The new function.
|
225
|
+
#
|
226
|
+
def ceiling(x)
|
227
|
+
Function.new(:CEILING,x)
|
228
|
+
end
|
229
|
+
|
230
|
+
#
|
231
|
+
# The `COS` function.
|
232
|
+
#
|
233
|
+
# @return [Function]
|
234
|
+
# The new function.
|
235
|
+
#
|
236
|
+
def cos(x)
|
237
|
+
Function.new(:COS,x)
|
238
|
+
end
|
239
|
+
|
240
|
+
#
|
241
|
+
# The `COT` function.
|
242
|
+
#
|
243
|
+
# @return [Function]
|
244
|
+
# The new function.
|
245
|
+
#
|
246
|
+
def cot(x)
|
247
|
+
Function.new(:COT,x)
|
248
|
+
end
|
249
|
+
|
250
|
+
#
|
251
|
+
# The `DEGREES` function.
|
252
|
+
#
|
253
|
+
# @return [Function]
|
254
|
+
# The new function.
|
255
|
+
#
|
256
|
+
def degrees(x)
|
257
|
+
Function.new(:DEGREES,x)
|
258
|
+
end
|
259
|
+
|
260
|
+
#
|
261
|
+
# The `EXP` function.
|
262
|
+
#
|
263
|
+
# @return [Function]
|
264
|
+
# The new function.
|
265
|
+
#
|
266
|
+
def exp(x)
|
267
|
+
Function.new(:EXP,x)
|
268
|
+
end
|
269
|
+
|
270
|
+
#
|
271
|
+
# The `FLOOR` function.
|
272
|
+
#
|
273
|
+
# @return [Function]
|
274
|
+
# The new function.
|
275
|
+
#
|
276
|
+
def floor(x)
|
277
|
+
Function.new(:FLOOR,x)
|
278
|
+
end
|
279
|
+
|
280
|
+
#
|
281
|
+
# The `FORMAT` function.
|
282
|
+
#
|
283
|
+
# @return [Function]
|
284
|
+
# The new function.
|
285
|
+
#
|
286
|
+
def format(x,d)
|
287
|
+
Function.new(:FORMAT,x,d)
|
288
|
+
end
|
289
|
+
|
290
|
+
#
|
291
|
+
# The `GREATEST` function.
|
292
|
+
#
|
293
|
+
# @return [Function]
|
294
|
+
# The new function.
|
295
|
+
#
|
296
|
+
def greatest(*values)
|
297
|
+
Function.new(:GREATEST,*values)
|
298
|
+
end
|
299
|
+
|
300
|
+
#
|
301
|
+
# The `INTERVAL` function.
|
302
|
+
#
|
303
|
+
# @return [Function]
|
304
|
+
# The new function.
|
305
|
+
#
|
306
|
+
def interval(*values)
|
307
|
+
Function.new(:INTERVAL,*values)
|
308
|
+
end
|
309
|
+
|
310
|
+
#
|
311
|
+
# The `LEAST` function.
|
312
|
+
#
|
313
|
+
# @return [Function]
|
314
|
+
# The new function.
|
315
|
+
#
|
316
|
+
def least(*values)
|
317
|
+
Function.new(:LEAST,*values)
|
318
|
+
end
|
319
|
+
|
320
|
+
#
|
321
|
+
# The `LOG` function.
|
322
|
+
#
|
323
|
+
# @return [Function]
|
324
|
+
# The new function.
|
325
|
+
#
|
326
|
+
def log(*b,x)
|
327
|
+
Function.new(:LOG,*b,x)
|
328
|
+
end
|
329
|
+
|
330
|
+
#
|
331
|
+
# The `LOG10` function.
|
332
|
+
#
|
333
|
+
# @return [Function]
|
334
|
+
# The new function.
|
335
|
+
#
|
336
|
+
def log10(x)
|
337
|
+
Function.new(:LOG10,x)
|
338
|
+
end
|
339
|
+
|
340
|
+
#
|
341
|
+
# The `MOD` function.
|
342
|
+
#
|
343
|
+
# @return [Function]
|
344
|
+
# The new function.
|
345
|
+
#
|
346
|
+
def mod(n,m)
|
347
|
+
Function.new(:MOD,n,m)
|
348
|
+
end
|
349
|
+
|
350
|
+
#
|
351
|
+
# The `PI` function.
|
352
|
+
#
|
353
|
+
# @return [Function]
|
354
|
+
# The new function.
|
355
|
+
#
|
356
|
+
def pi
|
357
|
+
Function.new(:PI)
|
358
|
+
end
|
359
|
+
|
360
|
+
#
|
361
|
+
# The `POW` function.
|
362
|
+
#
|
363
|
+
# @return [Function]
|
364
|
+
# The new function.
|
365
|
+
#
|
366
|
+
def pow(x,y)
|
367
|
+
Function.new(:POW,x,y)
|
368
|
+
end
|
369
|
+
|
370
|
+
#
|
371
|
+
# The `POWER` function.
|
372
|
+
#
|
373
|
+
# @return [Function]
|
374
|
+
# The new function.
|
375
|
+
#
|
376
|
+
def power(x,y)
|
377
|
+
Function.new(:POWER,x,y)
|
378
|
+
end
|
379
|
+
|
380
|
+
#
|
381
|
+
# The `RADIANS` function.
|
382
|
+
#
|
383
|
+
# @return [Function]
|
384
|
+
# The new function.
|
385
|
+
#
|
386
|
+
def radians(x)
|
387
|
+
Function.new(:RADIANS,x)
|
388
|
+
end
|
389
|
+
|
390
|
+
#
|
391
|
+
# The `RANDOM` function.
|
392
|
+
#
|
393
|
+
# @return [Function]
|
394
|
+
# The new function.
|
395
|
+
#
|
396
|
+
def random
|
397
|
+
Function.new(:RANDOM)
|
398
|
+
end
|
399
|
+
|
400
|
+
#
|
401
|
+
# The `ROUND` function.
|
402
|
+
#
|
403
|
+
# @return [Function]
|
404
|
+
# The new function.
|
405
|
+
#
|
406
|
+
def round(x,d=nil)
|
407
|
+
if d then Function.new(:ROUND,x,d)
|
408
|
+
else Function.new(:ROUND,x)
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
#
|
413
|
+
# The `SIGN` function.
|
414
|
+
#
|
415
|
+
# @return [Function]
|
416
|
+
# The new function.
|
417
|
+
#
|
418
|
+
def sign(x)
|
419
|
+
Function.new(:SIGN,x)
|
420
|
+
end
|
421
|
+
|
422
|
+
#
|
423
|
+
# The `SIN` function.
|
424
|
+
#
|
425
|
+
# @return [Function]
|
426
|
+
# The new function.
|
427
|
+
#
|
428
|
+
def sin(x)
|
429
|
+
Function.new(:SIN,x)
|
430
|
+
end
|
431
|
+
|
432
|
+
#
|
433
|
+
# The `SQRT` function.
|
434
|
+
#
|
435
|
+
# @return [Function]
|
436
|
+
# The new function.
|
437
|
+
#
|
438
|
+
def sqrt(x)
|
439
|
+
Function.new(:SQRT,x)
|
440
|
+
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# The `STD` function.
|
444
|
+
#
|
445
|
+
# @return [Function]
|
446
|
+
# The new function.
|
447
|
+
#
|
448
|
+
def std(field)
|
449
|
+
Function.new(:STD,field)
|
450
|
+
end
|
451
|
+
|
452
|
+
#
|
453
|
+
# The `STDDEV` function.
|
454
|
+
#
|
455
|
+
# @return [Function]
|
456
|
+
# The new function.
|
457
|
+
#
|
458
|
+
def stddev(field)
|
459
|
+
Function.new(:STDDEV,field)
|
460
|
+
end
|
461
|
+
|
462
|
+
#
|
463
|
+
# The `TAN` function.
|
464
|
+
#
|
465
|
+
# @return [Function]
|
466
|
+
# The new function.
|
467
|
+
#
|
468
|
+
def tan(x)
|
469
|
+
Function.new(:TAN,x)
|
470
|
+
end
|
471
|
+
|
472
|
+
#
|
473
|
+
# The `TRUNCATE` function.
|
474
|
+
#
|
475
|
+
# @return [Function]
|
476
|
+
# The new function.
|
477
|
+
#
|
478
|
+
def truncate(x,d)
|
479
|
+
Function.new(:TRUNCATE,x,d)
|
480
|
+
end
|
481
|
+
|
482
|
+
#
|
483
|
+
# @!group String Functions
|
484
|
+
#
|
485
|
+
|
486
|
+
#
|
487
|
+
# The `ASCII` function.
|
488
|
+
#
|
489
|
+
# @return [Function]
|
490
|
+
# The new function.
|
491
|
+
#
|
492
|
+
def ascii(string)
|
493
|
+
Function.new(:ASCII,string)
|
494
|
+
end
|
495
|
+
|
496
|
+
#
|
497
|
+
# The `BIN` function.
|
498
|
+
#
|
499
|
+
# @return [Function]
|
500
|
+
# The new function.
|
501
|
+
#
|
502
|
+
def bin(n)
|
503
|
+
Function.new(:BIN,n)
|
504
|
+
end
|
505
|
+
|
506
|
+
#
|
507
|
+
# The `BIT_LENGTH` function.
|
508
|
+
#
|
509
|
+
# @return [Function]
|
510
|
+
# The new function.
|
511
|
+
#
|
512
|
+
def bit_length(string)
|
513
|
+
Function.new(:BIT_LENGTH,string)
|
514
|
+
end
|
515
|
+
|
516
|
+
#
|
517
|
+
# The `CHAR` function.
|
518
|
+
#
|
519
|
+
# @return [Function]
|
520
|
+
# The new function.
|
521
|
+
#
|
522
|
+
def char(*bytes)
|
523
|
+
Function.new(:CHAR,*bytes)
|
524
|
+
end
|
525
|
+
|
526
|
+
#
|
527
|
+
# The `CHAR_LENGTH` function.
|
528
|
+
#
|
529
|
+
# @return [Function]
|
530
|
+
# The new function.
|
531
|
+
#
|
532
|
+
def char_length(string)
|
533
|
+
Function.new(:CHAR_LENGTH,string)
|
534
|
+
end
|
535
|
+
|
536
|
+
#
|
537
|
+
# The `CHARACTER_LENGTH` function.
|
538
|
+
#
|
539
|
+
# @return [Function]
|
540
|
+
# The new function.
|
541
|
+
#
|
542
|
+
def character_length(string)
|
543
|
+
Function.new(:CHARACTER_LENGTH,string)
|
544
|
+
end
|
545
|
+
|
546
|
+
#
|
547
|
+
# The `CONCAT` function.
|
548
|
+
#
|
549
|
+
# @return [Function]
|
550
|
+
# The new function.
|
551
|
+
#
|
552
|
+
def concat(*strings)
|
553
|
+
Function.new(:CONCAT,*strings)
|
554
|
+
end
|
555
|
+
|
556
|
+
#
|
557
|
+
# The `CONCAT_WS` function.
|
558
|
+
#
|
559
|
+
# @return [Function]
|
560
|
+
# The new function.
|
561
|
+
#
|
562
|
+
def concat_ws(separator,*strings)
|
563
|
+
Function.new(:CONCAT_WS,separator,*strings)
|
564
|
+
end
|
565
|
+
|
566
|
+
#
|
567
|
+
# The `CONV` function.
|
568
|
+
#
|
569
|
+
# @return [Function]
|
570
|
+
# The new function.
|
571
|
+
#
|
572
|
+
def conv(n,from_base,to_base)
|
573
|
+
Function.new(:CONV,n,from_base,to_base)
|
574
|
+
end
|
575
|
+
|
576
|
+
#
|
577
|
+
# The `ELT` function.
|
578
|
+
#
|
579
|
+
# @return [Function]
|
580
|
+
# The new function.
|
581
|
+
#
|
582
|
+
def elt(n,*strings)
|
583
|
+
Function.new(:ELT,n,*strings)
|
584
|
+
end
|
585
|
+
|
586
|
+
#
|
587
|
+
# The `EXPORT_SET` function.
|
588
|
+
#
|
589
|
+
# @return [Function]
|
590
|
+
# The new function.
|
591
|
+
#
|
592
|
+
def export_set(bits,on,off,separator=nil,number_of_bits=nil)
|
593
|
+
if (separator && number_of_bits)
|
594
|
+
Function.new(:EXPORT_SET,bits,on,off,separator,number_of_bits)
|
595
|
+
elsif separator
|
596
|
+
Function.new(:EXPORT_SET,bits,on,off,separator)
|
597
|
+
else
|
598
|
+
Function.new(:EXPORT_SET,bits,on,off)
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
#
|
603
|
+
# The `FIELD` function.
|
604
|
+
#
|
605
|
+
# @return [Function]
|
606
|
+
# The new function.
|
607
|
+
#
|
608
|
+
def field(*strings)
|
609
|
+
Function.new(:FIELD,*strings)
|
610
|
+
end
|
611
|
+
|
612
|
+
#
|
613
|
+
# The `FIND_IN_SET` function.
|
614
|
+
#
|
615
|
+
# @return [Function]
|
616
|
+
# The new function.
|
617
|
+
#
|
618
|
+
def find_in_set(string,*set)
|
619
|
+
Function.new(:FIND_IN_SET,string,*set)
|
620
|
+
end
|
621
|
+
|
622
|
+
#
|
623
|
+
# The `GLOB` function.
|
624
|
+
#
|
625
|
+
# @return [Function]
|
626
|
+
# The new function.
|
627
|
+
#
|
628
|
+
def glob(x,y)
|
629
|
+
Function.new(:GLOB,x,y)
|
630
|
+
end
|
631
|
+
|
632
|
+
#
|
633
|
+
# The `HEX` function.
|
634
|
+
#
|
635
|
+
# @return [Function]
|
636
|
+
# The new function.
|
637
|
+
#
|
638
|
+
def hex(value)
|
639
|
+
Function.new(:HEX,value)
|
640
|
+
end
|
641
|
+
|
642
|
+
#
|
643
|
+
# The `INSERT` function.
|
644
|
+
#
|
645
|
+
# @return [Function]
|
646
|
+
# The new function.
|
647
|
+
#
|
648
|
+
def insert(string,position,length,new_string)
|
649
|
+
Function.new(:INSERT,string,position,length,new_string)
|
650
|
+
end
|
651
|
+
|
652
|
+
#
|
653
|
+
# The `INSTR` function.
|
654
|
+
#
|
655
|
+
# @return [Function]
|
656
|
+
# The new function.
|
657
|
+
#
|
658
|
+
def instr(string,sub_string)
|
659
|
+
Function.new(:INSTR,string,sub_string)
|
660
|
+
end
|
661
|
+
|
662
|
+
#
|
663
|
+
# The `LCASE` function.
|
664
|
+
#
|
665
|
+
# @return [Function]
|
666
|
+
# The new function.
|
667
|
+
#
|
668
|
+
def lcase(string)
|
669
|
+
Function.new(:LCASE,string)
|
670
|
+
end
|
671
|
+
|
672
|
+
#
|
673
|
+
# The `LEFT` function.
|
674
|
+
#
|
675
|
+
# @return [Function]
|
676
|
+
# The new function.
|
677
|
+
#
|
678
|
+
def left(string,length)
|
679
|
+
Function.new(:LEFT,string,length)
|
680
|
+
end
|
681
|
+
|
682
|
+
#
|
683
|
+
# The `LENGTH` function.
|
684
|
+
#
|
685
|
+
# @return [Function]
|
686
|
+
# The new function.
|
687
|
+
#
|
688
|
+
def length(string)
|
689
|
+
Function.new(:LENGTH,string)
|
690
|
+
end
|
691
|
+
|
692
|
+
#
|
693
|
+
# The `LIKE` function.
|
694
|
+
#
|
695
|
+
# @return [Function]
|
696
|
+
# The new function.
|
697
|
+
#
|
698
|
+
def like(x,y,options=nil)
|
699
|
+
if options then Function.new(:LIKE,x,y,options)
|
700
|
+
else Function.new(:LIKE,x,y)
|
701
|
+
end
|
702
|
+
end
|
703
|
+
|
704
|
+
#
|
705
|
+
# The `LOAD_FILE` function.
|
706
|
+
#
|
707
|
+
# @return [Function]
|
708
|
+
# The new function.
|
709
|
+
#
|
710
|
+
def load_file(file_name)
|
711
|
+
Function.new(:LOAD_FILE,file_name)
|
712
|
+
end
|
713
|
+
|
714
|
+
#
|
715
|
+
# The `LOCATE` function.
|
716
|
+
#
|
717
|
+
# @return [Function]
|
718
|
+
# The new function.
|
719
|
+
#
|
720
|
+
def locate(sub_string,string,pos=nil)
|
721
|
+
if pos then Function.new(:LOCATE,sub_string,string,pos)
|
722
|
+
else Function.new(:LOCATE,sub_string,string)
|
723
|
+
end
|
724
|
+
end
|
725
|
+
|
726
|
+
#
|
727
|
+
# The `LOWER` function.
|
728
|
+
#
|
729
|
+
# @return [Function]
|
730
|
+
# The new function.
|
731
|
+
#
|
732
|
+
def lower(string)
|
733
|
+
Function.new(:LOWER,string)
|
734
|
+
end
|
735
|
+
|
736
|
+
#
|
737
|
+
# The `LPAD` function.
|
738
|
+
#
|
739
|
+
# @return [Function]
|
740
|
+
# The new function.
|
741
|
+
#
|
742
|
+
def lpad(string,length,pad_string)
|
743
|
+
Function.new(:LPAD,string,length,pad_string)
|
744
|
+
end
|
745
|
+
|
746
|
+
#
|
747
|
+
# The `LTRIM` function.
|
748
|
+
#
|
749
|
+
# @return [Function]
|
750
|
+
# The new function.
|
751
|
+
#
|
752
|
+
def ltrim(string)
|
753
|
+
Function.new(:LTRIM,string)
|
754
|
+
end
|
755
|
+
|
756
|
+
#
|
757
|
+
# The `MAKE_SET` function.
|
758
|
+
#
|
759
|
+
# @return [Function]
|
760
|
+
# The new function.
|
761
|
+
#
|
762
|
+
def make_set(bits,*strings)
|
763
|
+
Function.new(:MAKE_SET,bits,*strings)
|
764
|
+
end
|
765
|
+
|
766
|
+
#
|
767
|
+
# The `MID` function.
|
768
|
+
#
|
769
|
+
# @return [Function]
|
770
|
+
# The new function.
|
771
|
+
#
|
772
|
+
def mid(string,position,length)
|
773
|
+
Function.new(:MID,string,position,length)
|
774
|
+
end
|
775
|
+
|
776
|
+
#
|
777
|
+
# The `OCT` function.
|
778
|
+
#
|
779
|
+
# @return [Function]
|
780
|
+
# The new function.
|
781
|
+
#
|
782
|
+
def oct(n)
|
783
|
+
Function.new(:OCT,n)
|
784
|
+
end
|
785
|
+
|
786
|
+
#
|
787
|
+
# The `OCTET_LENGTH` function.
|
788
|
+
#
|
789
|
+
# @return [Function]
|
790
|
+
# The new function.
|
791
|
+
#
|
792
|
+
def octet_length(string)
|
793
|
+
Function.new(:OCTET_LENGTH,string)
|
794
|
+
end
|
795
|
+
|
796
|
+
#
|
797
|
+
# The `ORD` function.
|
798
|
+
#
|
799
|
+
# @return [Function]
|
800
|
+
# The new function.
|
801
|
+
#
|
802
|
+
def ord(string)
|
803
|
+
Function.new(:ORD,string)
|
804
|
+
end
|
805
|
+
|
806
|
+
#
|
807
|
+
# The `POSITION` function.
|
808
|
+
#
|
809
|
+
# @return [Function]
|
810
|
+
# The new function.
|
811
|
+
#
|
812
|
+
def position(expr)
|
813
|
+
Function.new(:POSITION,expr)
|
814
|
+
end
|
815
|
+
|
816
|
+
#
|
817
|
+
# The `QUOTE` function.
|
818
|
+
#
|
819
|
+
# @return [Function]
|
820
|
+
# The new function.
|
821
|
+
#
|
822
|
+
def quote(string)
|
823
|
+
Function.new(:QUOTE,string)
|
824
|
+
end
|
825
|
+
|
826
|
+
#
|
827
|
+
# The `REPEAT` function.
|
828
|
+
#
|
829
|
+
# @return [Function]
|
830
|
+
# The new function.
|
831
|
+
#
|
832
|
+
def repeat(string,count)
|
833
|
+
Function.new(:REPEAT,string,count)
|
834
|
+
end
|
835
|
+
|
836
|
+
#
|
837
|
+
# The `REPLACE` function.
|
838
|
+
#
|
839
|
+
# @return [Function]
|
840
|
+
# The new function.
|
841
|
+
#
|
842
|
+
def replace(string,from_string,to_string)
|
843
|
+
Function.new(:REPLACE,string,from_string,to_string)
|
844
|
+
end
|
845
|
+
|
846
|
+
#
|
847
|
+
# The `REVERSE` function.
|
848
|
+
#
|
849
|
+
# @return [Function]
|
850
|
+
# The new function.
|
851
|
+
#
|
852
|
+
def reverse(string)
|
853
|
+
Function.new(:REVERSE,string)
|
854
|
+
end
|
855
|
+
|
856
|
+
#
|
857
|
+
# The `RIGHT` function.
|
858
|
+
#
|
859
|
+
# @return [Function]
|
860
|
+
# The new function.
|
861
|
+
#
|
862
|
+
def right(string,length)
|
863
|
+
Function.new(:RIGHT,string,length)
|
864
|
+
end
|
865
|
+
|
866
|
+
#
|
867
|
+
# The `RPAD` function.
|
868
|
+
#
|
869
|
+
# @return [Function]
|
870
|
+
# The new function.
|
871
|
+
#
|
872
|
+
def rpad(string,length,pad_string)
|
873
|
+
Function.new(:RPAD,string,length,pad_string)
|
874
|
+
end
|
875
|
+
|
876
|
+
#
|
877
|
+
# The `RTRIM` function.
|
878
|
+
#
|
879
|
+
# @return [Function]
|
880
|
+
# The new function.
|
881
|
+
#
|
882
|
+
def rtrim(string)
|
883
|
+
Function.new(:RTRIM,string)
|
884
|
+
end
|
885
|
+
|
886
|
+
#
|
887
|
+
# The `SOUNDEX` function.
|
888
|
+
#
|
889
|
+
# @return [Function]
|
890
|
+
# The new function.
|
891
|
+
#
|
892
|
+
def soundex(string)
|
893
|
+
Function.new(:SOUNDEX,string)
|
894
|
+
end
|
895
|
+
|
896
|
+
#
|
897
|
+
# The `SPACE` function.
|
898
|
+
#
|
899
|
+
# @return [Function]
|
900
|
+
# The new function.
|
901
|
+
#
|
902
|
+
def space(n)
|
903
|
+
Function.new(:SPACE,n)
|
904
|
+
end
|
905
|
+
|
906
|
+
#
|
907
|
+
# The `STRCMP` function.
|
908
|
+
#
|
909
|
+
# @return [Function]
|
910
|
+
# The new function.
|
911
|
+
#
|
912
|
+
def strcmp(string1,string2)
|
913
|
+
Function.new(:STRCMP,string1,string2)
|
914
|
+
end
|
915
|
+
|
916
|
+
#
|
917
|
+
# The `SUBSTRING` function.
|
918
|
+
#
|
919
|
+
# @return [Function]
|
920
|
+
# The new function.
|
921
|
+
#
|
922
|
+
def substring(string,position,length=nil)
|
923
|
+
if length then Function.new(:SUBSTRING,string,position,length)
|
924
|
+
else Function.new(:SUBSTRING,string,position)
|
925
|
+
end
|
926
|
+
end
|
927
|
+
|
928
|
+
#
|
929
|
+
# The `SUBSTRING_INDEX` function.
|
930
|
+
#
|
931
|
+
# @return [Function]
|
932
|
+
# The new function.
|
933
|
+
#
|
934
|
+
def substring_index(string,deliminator,count)
|
935
|
+
Function.new(:SUBSTRING_INDEX,string,deliminator,count)
|
936
|
+
end
|
937
|
+
|
938
|
+
#
|
939
|
+
# The `TRIM` function.
|
940
|
+
#
|
941
|
+
# @param [String, Hash] string_or_options
|
942
|
+
#
|
943
|
+
# @option string_or_options [String] :both
|
944
|
+
#
|
945
|
+
# @option string_or_options [String] :leading
|
946
|
+
#
|
947
|
+
# @option string_or_options [String] :trailing
|
948
|
+
#
|
949
|
+
# @option string_or_options [String] :from
|
950
|
+
#
|
951
|
+
# @return [Function]
|
952
|
+
# The new function.
|
953
|
+
#
|
954
|
+
def trim(string_or_options)
|
955
|
+
Function.new(:TRIM,string_or_options)
|
956
|
+
end
|
957
|
+
|
958
|
+
#
|
959
|
+
# The `UCASE` function.
|
960
|
+
#
|
961
|
+
# @return [Function]
|
962
|
+
# The new function.
|
963
|
+
#
|
964
|
+
def ucase(string)
|
965
|
+
Function.new(:UCASE,string)
|
966
|
+
end
|
967
|
+
|
968
|
+
#
|
969
|
+
# The `UNHEX` function.
|
970
|
+
#
|
971
|
+
# @return [Function]
|
972
|
+
# The new function.
|
973
|
+
#
|
974
|
+
def unhex(string)
|
975
|
+
Function.new(:UNHEX,string)
|
976
|
+
end
|
977
|
+
|
978
|
+
#
|
979
|
+
# The `UPPER` function.
|
980
|
+
#
|
981
|
+
# @return [Function]
|
982
|
+
# The new function.
|
983
|
+
#
|
984
|
+
def upper(string)
|
985
|
+
Function.new(:UPPER,string)
|
986
|
+
end
|
987
|
+
end
|
988
|
+
end
|
989
|
+
end
|