Module: Ronin::SQL::Functions
- Included in:
- Clause, InjectionExpr, StatementList
- Defined in:
- lib/ronin/sql/functions.rb
Overview
Methods for creating common SQL Functions.
Aggregate Functions collapse
-
#avg(field) ⇒ Function
The
AVG
function. -
#count(field = :*) ⇒ Function
The
COUNT
function. -
#max(field) ⇒ Function
The
MAX
function. -
#min(field) ⇒ Function
The
MIN
function. -
#rand(field) ⇒ Function
The
RAND
function. -
#sum(field) ⇒ Function
The
SUM
function.
Numeric Functions collapse
-
#abs(x) ⇒ Function
The
ABS
function. -
#acos(x) ⇒ Function
The
ACOS
function. -
#asin(x) ⇒ Function
The
ASIN
function. -
#atan(x) ⇒ Function
The
ATAN
function. -
#atan2(y, x) ⇒ Function
The
ATAN2
function. -
#bit_and(x) ⇒ Function
The
BIT_AND
function. -
#bit_count(x) ⇒ Function
The
BIT_COUNT
function. -
#bit_or(x) ⇒ Function
The
BIT_OR
function. -
#ceil(x) ⇒ Function
The
CEIL
function. -
#ceiling(x) ⇒ Function
The
CEILING
function. -
#cos(x) ⇒ Function
The
COS
function. -
#cot(x) ⇒ Function
The
COT
function. -
#degrees(x) ⇒ Function
The
DEGREES
function. -
#exp(x) ⇒ Function
The
EXP
function. -
#floor(x) ⇒ Function
The
FLOOR
function. -
#format(x, d) ⇒ Function
The
FORMAT
function. -
#greatest(*values) ⇒ Function
The
GREATEST
function. -
#interval(*values) ⇒ Function
The
INTERVAL
function. -
#least(*values) ⇒ Function
The
LEAST
function. -
#log(*b, x) ⇒ Function
The
LOG
function. -
#log10(x) ⇒ Function
The
LOG10
function. -
#mod(n, m) ⇒ Function
The
MOD
function. -
#pi ⇒ Function
The
PI
function. -
#pow(x, y) ⇒ Function
The
POW
function. -
#power(x, y) ⇒ Function
The
POWER
function. -
#radians(x) ⇒ Function
The
RADIANS
function. -
#random ⇒ Function
The
RANDOM
function. -
#round(x, d = nil) ⇒ Function
The
ROUND
function. -
#sign(x) ⇒ Function
The
SIGN
function. -
#sin(x) ⇒ Function
The
SIN
function. -
#sqrt(x) ⇒ Function
The
SQRT
function. -
#std(field) ⇒ Function
The
STD
function. -
#stddev(field) ⇒ Function
The
STDDEV
function. -
#tan(x) ⇒ Function
The
TAN
function. -
#truncate(x, d) ⇒ Function
The
TRUNCATE
function.
String Functions collapse
-
#ascii(string) ⇒ Function
The
ASCII
function. -
#bin(n) ⇒ Function
The
BIN
function. -
#bit_length(string) ⇒ Function
The
BIT_LENGTH
function. -
#char(*bytes) ⇒ Function
The
CHAR
function. -
#char_length(string) ⇒ Function
The
CHAR_LENGTH
function. -
#character_length(string) ⇒ Function
The
CHARACTER_LENGTH
function. -
#concat(*strings) ⇒ Function
The
CONCAT
function. -
#concat_ws(separator, *strings) ⇒ Function
The
CONCAT_WS
function. -
#conv(n, from_base, to_base) ⇒ Function
The
CONV
function. -
#elt(n, *strings) ⇒ Function
The
ELT
function. -
#export_set(bits, on, off, separator = nil, number_of_bits = nil) ⇒ Function
The
EXPORT_SET
function. -
#field(*strings) ⇒ Function
The
FIELD
function. -
#find_in_set(string, *set) ⇒ Function
The
FIND_IN_SET
function. -
#glob(x, y) ⇒ Function
The
GLOB
function. -
#hex(value) ⇒ Function
The
HEX
function. -
#insert(string, position, length, new_string) ⇒ Function
The
INSERT
function. -
#instr(string, sub_string) ⇒ Function
The
INSTR
function. -
#lcase(string) ⇒ Function
The
LCASE
function. -
#left(string, length) ⇒ Function
The
LEFT
function. -
#length(string) ⇒ Function
The
LENGTH
function. -
#like(x, y, options = nil) ⇒ Function
The
LIKE
function. -
#load_file(file_name) ⇒ Function
The
LOAD_FILE
function. -
#locate(sub_string, string, pos = nil) ⇒ Function
The
LOCATE
function. -
#lower(string) ⇒ Function
The
LOWER
function. -
#lpad(string, length, pad_string) ⇒ Function
The
LPAD
function. -
#ltrim(string) ⇒ Function
The
LTRIM
function. -
#make_set(bits, *strings) ⇒ Function
The
MAKE_SET
function. -
#mid(string, position, length) ⇒ Function
The
MID
function. -
#oct(n) ⇒ Function
The
OCT
function. -
#octet_length(string) ⇒ Function
The
OCTET_LENGTH
function. -
#ord(string) ⇒ Function
The
ORD
function. -
#position(expr) ⇒ Function
The
POSITION
function. -
#quote(string) ⇒ Function
The
QUOTE
function. -
#repeat(string, count) ⇒ Function
The
REPEAT
function. -
#replace(string, from_string, to_string) ⇒ Function
The
REPLACE
function. -
#reverse(string) ⇒ Function
The
REVERSE
function. -
#right(string, length) ⇒ Function
The
RIGHT
function. -
#rpad(string, length, pad_string) ⇒ Function
The
RPAD
function. -
#rtrim(string) ⇒ Function
The
RTRIM
function. -
#soundex(string) ⇒ Function
The
SOUNDEX
function. -
#space(n) ⇒ Function
The
SPACE
function. -
#strcmp(string1, string2) ⇒ Function
The
STRCMP
function. -
#substring(string, position, length = nil) ⇒ Function
The
SUBSTRING
function. -
#substring_index(string, deliminator, count) ⇒ Function
The
SUBSTRING_INDEX
function. -
#trim(string_or_options) ⇒ Function
The
TRIM
function. -
#ucase(string) ⇒ Function
The
UCASE
function. -
#unhex(string) ⇒ Function
The
UNHEX
function. -
#upper(string) ⇒ Function
The
UPPER
function.
Instance Method Details
#abs(x) ⇒ Function
The ABS
function.
138 139 140 |
# File 'lib/ronin/sql/functions.rb', line 138 def abs(x) Function.new(:ABS,x) end |
#acos(x) ⇒ Function
The ACOS
function.
148 149 150 |
# File 'lib/ronin/sql/functions.rb', line 148 def acos(x) Function.new(:ACOS,x) end |
#ascii(string) ⇒ Function
The ASCII
function.
494 495 496 |
# File 'lib/ronin/sql/functions.rb', line 494 def ascii(string) Function.new(:ASCII,string) end |
#asin(x) ⇒ Function
The ASIN
function.
158 159 160 |
# File 'lib/ronin/sql/functions.rb', line 158 def asin(x) Function.new(:ASIN,x) end |
#atan(x) ⇒ Function
The ATAN
function.
168 169 170 |
# File 'lib/ronin/sql/functions.rb', line 168 def atan(x) Function.new(:ATAN,x) end |
#atan2(y, x) ⇒ Function
The ATAN2
function.
178 179 180 |
# File 'lib/ronin/sql/functions.rb', line 178 def atan2(y,x) Function.new(:ATAN2,y,x) end |
#avg(field) ⇒ Function
The AVG
function.
85 86 87 |
# File 'lib/ronin/sql/functions.rb', line 85 def avg(field) Function.new(:AVG,field) end |
#bin(n) ⇒ Function
The BIN
function.
504 505 506 |
# File 'lib/ronin/sql/functions.rb', line 504 def bin(n) Function.new(:BIN,n) end |
#bit_and(x) ⇒ Function
The BIT_AND
function.
188 189 190 |
# File 'lib/ronin/sql/functions.rb', line 188 def bit_and(x) Function.new(:BIT_AND,x) end |
#bit_count(x) ⇒ Function
The BIT_COUNT
function.
198 199 200 |
# File 'lib/ronin/sql/functions.rb', line 198 def bit_count(x) Function.new(:BIT_COUNT,x) end |
#bit_length(string) ⇒ Function
The BIT_LENGTH
function.
514 515 516 |
# File 'lib/ronin/sql/functions.rb', line 514 def bit_length(string) Function.new(:BIT_LENGTH,string) end |
#bit_or(x) ⇒ Function
The BIT_OR
function.
208 209 210 |
# File 'lib/ronin/sql/functions.rb', line 208 def bit_or(x) Function.new(:BIT_OR,x) end |
#ceil(x) ⇒ Function
The CEIL
function.
218 219 220 |
# File 'lib/ronin/sql/functions.rb', line 218 def ceil(x) Function.new(:CEIL,x) end |
#ceiling(x) ⇒ Function
The CEILING
function.
228 229 230 |
# File 'lib/ronin/sql/functions.rb', line 228 def ceiling(x) Function.new(:CEILING,x) end |
#char(*bytes) ⇒ Function
The CHAR
function.
524 525 526 |
# File 'lib/ronin/sql/functions.rb', line 524 def char(*bytes) Function.new(:CHAR,*bytes) end |
#char_length(string) ⇒ Function
The CHAR_LENGTH
function.
534 535 536 |
# File 'lib/ronin/sql/functions.rb', line 534 def char_length(string) Function.new(:CHAR_LENGTH,string) end |
#character_length(string) ⇒ Function
The CHARACTER_LENGTH
function.
544 545 546 |
# File 'lib/ronin/sql/functions.rb', line 544 def character_length(string) Function.new(:CHARACTER_LENGTH,string) end |
#concat(*strings) ⇒ Function
The CONCAT
function.
554 555 556 |
# File 'lib/ronin/sql/functions.rb', line 554 def concat(*strings) Function.new(:CONCAT,*strings) end |
#concat_ws(separator, *strings) ⇒ Function
The CONCAT_WS
function.
564 565 566 |
# File 'lib/ronin/sql/functions.rb', line 564 def concat_ws(separator,*strings) Function.new(:CONCAT_WS,separator,*strings) end |
#conv(n, from_base, to_base) ⇒ Function
The CONV
function.
574 575 576 |
# File 'lib/ronin/sql/functions.rb', line 574 def conv(n,from_base,to_base) Function.new(:CONV,n,from_base,to_base) end |
#cos(x) ⇒ Function
The COS
function.
238 239 240 |
# File 'lib/ronin/sql/functions.rb', line 238 def cos(x) Function.new(:COS,x) end |
#cot(x) ⇒ Function
The COT
function.
248 249 250 |
# File 'lib/ronin/sql/functions.rb', line 248 def cot(x) Function.new(:COT,x) end |
#count(field = :*) ⇒ Function
The COUNT
function.
46 47 48 |
# File 'lib/ronin/sql/functions.rb', line 46 def count(field=:*) Function.new(:COUNT,field) end |
#degrees(x) ⇒ Function
The DEGREES
function.
258 259 260 |
# File 'lib/ronin/sql/functions.rb', line 258 def degrees(x) Function.new(:DEGREES,x) end |
#elt(n, *strings) ⇒ Function
The ELT
function.
584 585 586 |
# File 'lib/ronin/sql/functions.rb', line 584 def elt(n,*strings) Function.new(:ELT,n,*strings) end |
#exp(x) ⇒ Function
The EXP
function.
268 269 270 |
# File 'lib/ronin/sql/functions.rb', line 268 def exp(x) Function.new(:EXP,x) end |
#export_set(bits, on, off, separator = nil, number_of_bits = nil) ⇒ Function
The EXPORT_SET
function.
594 595 596 597 598 599 600 601 602 |
# File 'lib/ronin/sql/functions.rb', line 594 def export_set(bits,on,off,separator=nil,number_of_bits=nil) if (separator && number_of_bits) Function.new(:EXPORT_SET,bits,on,off,separator,number_of_bits) elsif separator Function.new(:EXPORT_SET,bits,on,off,separator) else Function.new(:EXPORT_SET,bits,on,off) end end |
#field(*strings) ⇒ Function
The FIELD
function.
610 611 612 |
# File 'lib/ronin/sql/functions.rb', line 610 def field(*strings) Function.new(:FIELD,*strings) end |
#find_in_set(string, *set) ⇒ Function
The FIND_IN_SET
function.
620 621 622 |
# File 'lib/ronin/sql/functions.rb', line 620 def find_in_set(string,*set) Function.new(:FIND_IN_SET,string,*set) end |
#floor(x) ⇒ Function
The FLOOR
function.
278 279 280 |
# File 'lib/ronin/sql/functions.rb', line 278 def floor(x) Function.new(:FLOOR,x) end |
#format(x, d) ⇒ Function
The FORMAT
function.
288 289 290 |
# File 'lib/ronin/sql/functions.rb', line 288 def format(x,d) Function.new(:FORMAT,x,d) end |
#glob(x, y) ⇒ Function
The GLOB
function.
630 631 632 |
# File 'lib/ronin/sql/functions.rb', line 630 def glob(x,y) Function.new(:GLOB,x,y) end |
#greatest(*values) ⇒ Function
The GREATEST
function.
298 299 300 |
# File 'lib/ronin/sql/functions.rb', line 298 def greatest(*values) Function.new(:GREATEST,*values) end |
#hex(value) ⇒ Function
The HEX
function.
640 641 642 |
# File 'lib/ronin/sql/functions.rb', line 640 def hex(value) Function.new(:HEX,value) end |
#insert(string, position, length, new_string) ⇒ Function
The INSERT
function.
650 651 652 |
# File 'lib/ronin/sql/functions.rb', line 650 def insert(string,position,length,new_string) Function.new(:INSERT,string,position,length,new_string) end |
#instr(string, sub_string) ⇒ Function
The INSTR
function.
660 661 662 |
# File 'lib/ronin/sql/functions.rb', line 660 def instr(string,sub_string) Function.new(:INSTR,string,sub_string) end |
#interval(*values) ⇒ Function
The INTERVAL
function.
308 309 310 |
# File 'lib/ronin/sql/functions.rb', line 308 def interval(*values) Function.new(:INTERVAL,*values) end |
#lcase(string) ⇒ Function
The LCASE
function.
670 671 672 |
# File 'lib/ronin/sql/functions.rb', line 670 def lcase(string) Function.new(:LCASE,string) end |
#least(*values) ⇒ Function
The LEAST
function.
318 319 320 |
# File 'lib/ronin/sql/functions.rb', line 318 def least(*values) Function.new(:LEAST,*values) end |
#left(string, length) ⇒ Function
The LEFT
function.
680 681 682 |
# File 'lib/ronin/sql/functions.rb', line 680 def left(string,length) Function.new(:LEFT,string,length) end |
#length(string) ⇒ Function
The LENGTH
function.
690 691 692 |
# File 'lib/ronin/sql/functions.rb', line 690 def length(string) Function.new(:LENGTH,string) end |
#like(x, y, options = nil) ⇒ Function
The LIKE
function.
700 701 702 703 704 |
# File 'lib/ronin/sql/functions.rb', line 700 def like(x,y,=nil) if then Function.new(:LIKE,x,y,) else Function.new(:LIKE,x,y) end end |
#load_file(file_name) ⇒ Function
The LOAD_FILE
function.
712 713 714 |
# File 'lib/ronin/sql/functions.rb', line 712 def load_file(file_name) Function.new(:LOAD_FILE,file_name) end |
#locate(sub_string, string, pos = nil) ⇒ Function
The LOCATE
function.
722 723 724 725 726 |
# File 'lib/ronin/sql/functions.rb', line 722 def locate(sub_string,string,pos=nil) if pos then Function.new(:LOCATE,sub_string,string,pos) else Function.new(:LOCATE,sub_string,string) end end |
#log(*b, x) ⇒ Function
The LOG
function.
328 329 330 |
# File 'lib/ronin/sql/functions.rb', line 328 def log(*b,x) Function.new(:LOG,*b,x) end |
#log10(x) ⇒ Function
The LOG10
function.
338 339 340 |
# File 'lib/ronin/sql/functions.rb', line 338 def log10(x) Function.new(:LOG10,x) end |
#lower(string) ⇒ Function
The LOWER
function.
734 735 736 |
# File 'lib/ronin/sql/functions.rb', line 734 def lower(string) Function.new(:LOWER,string) end |
#lpad(string, length, pad_string) ⇒ Function
The LPAD
function.
744 745 746 |
# File 'lib/ronin/sql/functions.rb', line 744 def lpad(string,length,pad_string) Function.new(:LPAD,string,length,pad_string) end |
#ltrim(string) ⇒ Function
The LTRIM
function.
754 755 756 |
# File 'lib/ronin/sql/functions.rb', line 754 def ltrim(string) Function.new(:LTRIM,string) end |
#make_set(bits, *strings) ⇒ Function
The MAKE_SET
function.
764 765 766 |
# File 'lib/ronin/sql/functions.rb', line 764 def make_set(bits,*strings) Function.new(:MAKE_SET,bits,*strings) end |
#max(field) ⇒ Function
The MAX
function.
59 60 61 |
# File 'lib/ronin/sql/functions.rb', line 59 def max(field) Function.new(:MAX,field) end |
#mid(string, position, length) ⇒ Function
The MID
function.
774 775 776 |
# File 'lib/ronin/sql/functions.rb', line 774 def mid(string,position,length) Function.new(:MID,string,position,length) end |
#min(field) ⇒ Function
The MIN
function.
72 73 74 |
# File 'lib/ronin/sql/functions.rb', line 72 def min(field) Function.new(:MIN,field) end |
#mod(n, m) ⇒ Function
The MOD
function.
348 349 350 |
# File 'lib/ronin/sql/functions.rb', line 348 def mod(n,m) Function.new(:MOD,n,m) end |
#oct(n) ⇒ Function
The OCT
function.
784 785 786 |
# File 'lib/ronin/sql/functions.rb', line 784 def oct(n) Function.new(:OCT,n) end |
#octet_length(string) ⇒ Function
The OCTET_LENGTH
function.
794 795 796 |
# File 'lib/ronin/sql/functions.rb', line 794 def octet_length(string) Function.new(:OCTET_LENGTH,string) end |
#ord(string) ⇒ Function
The ORD
function.
804 805 806 |
# File 'lib/ronin/sql/functions.rb', line 804 def ord(string) Function.new(:ORD,string) end |
#pi ⇒ Function
The PI
function.
358 359 360 |
# File 'lib/ronin/sql/functions.rb', line 358 def pi Function.new(:PI) end |
#position(expr) ⇒ Function
The POSITION
function.
814 815 816 |
# File 'lib/ronin/sql/functions.rb', line 814 def position(expr) Function.new(:POSITION,expr) end |
#pow(x, y) ⇒ Function
The POW
function.
368 369 370 |
# File 'lib/ronin/sql/functions.rb', line 368 def pow(x,y) Function.new(:POW,x,y) end |
#power(x, y) ⇒ Function
The POWER
function.
378 379 380 |
# File 'lib/ronin/sql/functions.rb', line 378 def power(x,y) Function.new(:POWER,x,y) end |
#quote(string) ⇒ Function
The QUOTE
function.
824 825 826 |
# File 'lib/ronin/sql/functions.rb', line 824 def quote(string) Function.new(:QUOTE,string) end |
#radians(x) ⇒ Function
The RADIANS
function.
388 389 390 |
# File 'lib/ronin/sql/functions.rb', line 388 def radians(x) Function.new(:RADIANS,x) end |
#rand(field) ⇒ Function
The RAND
function.
124 125 126 |
# File 'lib/ronin/sql/functions.rb', line 124 def rand(field) Function.new(:RAND,field) end |
#random ⇒ Function
The RANDOM
function.
398 399 400 |
# File 'lib/ronin/sql/functions.rb', line 398 def random Function.new(:RANDOM) end |
#repeat(string, count) ⇒ Function
The REPEAT
function.
834 835 836 |
# File 'lib/ronin/sql/functions.rb', line 834 def repeat(string,count) Function.new(:REPEAT,string,count) end |
#replace(string, from_string, to_string) ⇒ Function
The REPLACE
function.
844 845 846 |
# File 'lib/ronin/sql/functions.rb', line 844 def replace(string,from_string,to_string) Function.new(:REPLACE,string,from_string,to_string) end |
#reverse(string) ⇒ Function
The REVERSE
function.
854 855 856 |
# File 'lib/ronin/sql/functions.rb', line 854 def reverse(string) Function.new(:REVERSE,string) end |
#right(string, length) ⇒ Function
The RIGHT
function.
864 865 866 |
# File 'lib/ronin/sql/functions.rb', line 864 def right(string,length) Function.new(:RIGHT,string,length) end |
#round(x, d = nil) ⇒ Function
The ROUND
function.
408 409 410 411 412 |
# File 'lib/ronin/sql/functions.rb', line 408 def round(x,d=nil) if d then Function.new(:ROUND,x,d) else Function.new(:ROUND,x) end end |
#rpad(string, length, pad_string) ⇒ Function
The RPAD
function.
874 875 876 |
# File 'lib/ronin/sql/functions.rb', line 874 def rpad(string,length,pad_string) Function.new(:RPAD,string,length,pad_string) end |
#rtrim(string) ⇒ Function
The RTRIM
function.
884 885 886 |
# File 'lib/ronin/sql/functions.rb', line 884 def rtrim(string) Function.new(:RTRIM,string) end |
#sign(x) ⇒ Function
The SIGN
function.
420 421 422 |
# File 'lib/ronin/sql/functions.rb', line 420 def sign(x) Function.new(:SIGN,x) end |
#sin(x) ⇒ Function
The SIN
function.
430 431 432 |
# File 'lib/ronin/sql/functions.rb', line 430 def sin(x) Function.new(:SIN,x) end |
#soundex(string) ⇒ Function
The SOUNDEX
function.
894 895 896 |
# File 'lib/ronin/sql/functions.rb', line 894 def soundex(string) Function.new(:SOUNDEX,string) end |
#space(n) ⇒ Function
The SPACE
function.
904 905 906 |
# File 'lib/ronin/sql/functions.rb', line 904 def space(n) Function.new(:SPACE,n) end |
#sqrt(x) ⇒ Function
The SQRT
function.
111 112 113 |
# File 'lib/ronin/sql/functions.rb', line 111 def sqrt(field) Function.new(:SQRT,field) end |
#std(field) ⇒ Function
The STD
function.
450 451 452 |
# File 'lib/ronin/sql/functions.rb', line 450 def std(field) Function.new(:STD,field) end |
#stddev(field) ⇒ Function
The STDDEV
function.
460 461 462 |
# File 'lib/ronin/sql/functions.rb', line 460 def stddev(field) Function.new(:STDDEV,field) end |
#strcmp(string1, string2) ⇒ Function
The STRCMP
function.
914 915 916 |
# File 'lib/ronin/sql/functions.rb', line 914 def strcmp(string1,string2) Function.new(:STRCMP,string1,string2) end |
#substring(string, position, length = nil) ⇒ Function
The SUBSTRING
function.
924 925 926 927 928 |
# File 'lib/ronin/sql/functions.rb', line 924 def substring(string,position,length=nil) if length then Function.new(:SUBSTRING,string,position,length) else Function.new(:SUBSTRING,string,position) end end |
#substring_index(string, deliminator, count) ⇒ Function
The SUBSTRING_INDEX
function.
936 937 938 |
# File 'lib/ronin/sql/functions.rb', line 936 def substring_index(string,deliminator,count) Function.new(:SUBSTRING_INDEX,string,deliminator,count) end |
#sum(field) ⇒ Function
The SUM
function.
98 99 100 |
# File 'lib/ronin/sql/functions.rb', line 98 def sum(field) Function.new(:SUM,field) end |
#tan(x) ⇒ Function
The TAN
function.
470 471 472 |
# File 'lib/ronin/sql/functions.rb', line 470 def tan(x) Function.new(:TAN,x) end |
#trim(string_or_options) ⇒ Function
The TRIM
function.
956 957 958 |
# File 'lib/ronin/sql/functions.rb', line 956 def trim() Function.new(:TRIM,) end |
#truncate(x, d) ⇒ Function
The TRUNCATE
function.
480 481 482 |
# File 'lib/ronin/sql/functions.rb', line 480 def truncate(x,d) Function.new(:TRUNCATE,x,d) end |
#ucase(string) ⇒ Function
The UCASE
function.
966 967 968 |
# File 'lib/ronin/sql/functions.rb', line 966 def ucase(string) Function.new(:UCASE,string) end |