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
data/lib/ronin/formatting/sql.rb
CHANGED
@@ -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
|
data/lib/ronin/sql.rb
CHANGED
@@ -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,12 +20,4 @@
|
|
19
20
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
21
|
#
|
21
22
|
|
22
|
-
require 'ronin/sql/
|
23
|
-
require 'ronin/sql/error'
|
24
|
-
require 'ronin/sql/injection'
|
25
|
-
require 'ronin/sql/version'
|
26
|
-
require 'ronin/config'
|
27
|
-
|
28
|
-
module Ronin
|
29
|
-
Config.load :sql
|
30
|
-
end
|
23
|
+
require 'ronin/sql/sql'
|
@@ -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,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/
|
23
|
+
require 'ronin/sql/operators'
|
24
|
+
require 'ronin/sql/emittable'
|
24
25
|
|
25
26
|
module Ronin
|
26
|
-
module
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
module SQL
|
28
|
+
#
|
29
|
+
# Represents a binary expression in SQL.
|
30
|
+
#
|
31
|
+
class BinaryExpr < Struct.new(:left,:operator,:right)
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def index(name=nil)
|
37
|
-
@name = name if name
|
38
|
-
return @name
|
39
|
-
end
|
33
|
+
include Operators
|
34
|
+
include Emittable
|
40
35
|
|
36
|
+
#
|
37
|
+
# Converts the binary expression to SQL.
|
38
|
+
#
|
39
|
+
# @param [Hash] options
|
40
|
+
# Additional options for {Emitter#initialize}.
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
# The emitted SQL expression.
|
44
|
+
#
|
45
|
+
def to_sql(options={})
|
46
|
+
emitter(options).emit_expression(self)
|
41
47
|
end
|
48
|
+
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -0,0 +1,72 @@
|
|
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/literals'
|
24
|
+
require 'ronin/sql/fields'
|
25
|
+
require 'ronin/sql/functions'
|
26
|
+
require 'ronin/sql/statement'
|
27
|
+
require 'ronin/sql/statements'
|
28
|
+
require 'ronin/sql/emittable'
|
29
|
+
|
30
|
+
module Ronin
|
31
|
+
module SQL
|
32
|
+
#
|
33
|
+
# Represents a SQL Clause.
|
34
|
+
#
|
35
|
+
class Clause < Struct.new(:keyword,:argument)
|
36
|
+
|
37
|
+
include Literals
|
38
|
+
include Fields
|
39
|
+
include Functions
|
40
|
+
include Statements
|
41
|
+
include Emittable
|
42
|
+
|
43
|
+
#
|
44
|
+
# Initializes the SQL clause.
|
45
|
+
#
|
46
|
+
# @param [Symbol] keyword
|
47
|
+
# The name of the clause.
|
48
|
+
#
|
49
|
+
# @param [Object] argument
|
50
|
+
# Additional argument for the clause.
|
51
|
+
#
|
52
|
+
# @yield [(clause)]
|
53
|
+
# If a block is given, the return value will be used as the argument.
|
54
|
+
#
|
55
|
+
# @yieldparam [Clause] clause
|
56
|
+
# If the block accepts an argument, it will be passed the new clause.
|
57
|
+
# Otherwise the block will be evaluated within the clause.
|
58
|
+
#
|
59
|
+
def initialize(keyword,argument=nil,&block)
|
60
|
+
super(keyword,argument)
|
61
|
+
|
62
|
+
if block
|
63
|
+
self.argument = case block.arity
|
64
|
+
when 0 then instance_eval(&block)
|
65
|
+
else block.call(self)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,297 @@
|
|
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
|
+
module Ronin
|
24
|
+
module SQL
|
25
|
+
#
|
26
|
+
# Methods for creating common SQL {Clause Clauses}.
|
27
|
+
#
|
28
|
+
module Clauses
|
29
|
+
#
|
30
|
+
# The defined clauses of the statement.
|
31
|
+
#
|
32
|
+
# @return [Array<Clause>]
|
33
|
+
# The clauses defined thus far.
|
34
|
+
#
|
35
|
+
def clauses
|
36
|
+
@clauses ||= []
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Appends an arbitrary clause.
|
41
|
+
#
|
42
|
+
# @param [Symbol] keyword
|
43
|
+
# The name of the clause.
|
44
|
+
#
|
45
|
+
# @param [Object] argument
|
46
|
+
# Additional argument for the clause.
|
47
|
+
#
|
48
|
+
# @yield [(clause)]
|
49
|
+
# If a block is given, the return value will be used as the argument.
|
50
|
+
#
|
51
|
+
# @yieldparam [Clause] clause
|
52
|
+
# If the block accepts an argument, it will be passed the new clause.
|
53
|
+
# Otherwise the block will be evaluated within the clause.
|
54
|
+
#
|
55
|
+
# @return [self]
|
56
|
+
#
|
57
|
+
def clause(keyword,argument=nil,&block)
|
58
|
+
clauses << Clause.new(keyword,argument,&block)
|
59
|
+
return self
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Appends a `FROM` clause.
|
64
|
+
#
|
65
|
+
# @param [Field, Symbol] table
|
66
|
+
# The table to select from.
|
67
|
+
#
|
68
|
+
# @return [self]
|
69
|
+
#
|
70
|
+
def from(table=nil,&block)
|
71
|
+
clause(:FROM,table,&block)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Appends an `INTO` clause.
|
76
|
+
#
|
77
|
+
# @param [Field, Symbol] table
|
78
|
+
# The table to insert into.
|
79
|
+
#
|
80
|
+
# @return [self]
|
81
|
+
#
|
82
|
+
def into(table=nil,&block)
|
83
|
+
clause(:INTO,table,&block)
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Appends a `WHERE` clause.
|
88
|
+
#
|
89
|
+
# @return [self]
|
90
|
+
#
|
91
|
+
def where(&block)
|
92
|
+
clause(:WHERE,&block)
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Appends a `JOIN` clause.
|
97
|
+
#
|
98
|
+
# @param [Field, Symbol] table
|
99
|
+
# The table to join.
|
100
|
+
#
|
101
|
+
# @return [self]
|
102
|
+
#
|
103
|
+
def join(table=nil,&block)
|
104
|
+
clause(:JOIN,table,&block)
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Appends a `INNER JOIN` clause.
|
109
|
+
#
|
110
|
+
# @param [Field, Symbol] table
|
111
|
+
# The table to join.
|
112
|
+
#
|
113
|
+
# @return [self]
|
114
|
+
#
|
115
|
+
def inner_join(table=nil,&block)
|
116
|
+
clause([:INNER, :JOIN],table,&block)
|
117
|
+
end
|
118
|
+
|
119
|
+
#
|
120
|
+
# Appends a `LEFT JOIN` clause.
|
121
|
+
#
|
122
|
+
# @param [Field, Symbol] table
|
123
|
+
# The table to join.
|
124
|
+
#
|
125
|
+
# @return [self]
|
126
|
+
#
|
127
|
+
def left_join(table=nil,&block)
|
128
|
+
clause([:LEFT, :JOIN],table,&block)
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# Appends a `RIGHT JOIN` clause.
|
133
|
+
#
|
134
|
+
# @param [Field, Symbol] table
|
135
|
+
# The table to join.
|
136
|
+
#
|
137
|
+
# @return [self]
|
138
|
+
#
|
139
|
+
def right_join(table=nil,&block)
|
140
|
+
clause([:RIGHT, :JOIN],table,&block)
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# Appends a `FULL JOIN` clause.
|
145
|
+
#
|
146
|
+
# @param [Field, Symbol] table
|
147
|
+
# The table to join.
|
148
|
+
#
|
149
|
+
# @return [self]
|
150
|
+
#
|
151
|
+
def full_join(table=nil,&block)
|
152
|
+
clause([:FULL, :JOIN],table,&block)
|
153
|
+
end
|
154
|
+
|
155
|
+
#
|
156
|
+
# Appends a `ON` clause.
|
157
|
+
#
|
158
|
+
# @return [self]
|
159
|
+
#
|
160
|
+
def on(&block)
|
161
|
+
clause(:ON,&block)
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# Appends a `UNION` clause.
|
166
|
+
#
|
167
|
+
# @return [self]
|
168
|
+
#
|
169
|
+
def union(&block)
|
170
|
+
clause(:UNION,&block)
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Appends a `GROUP BY` clause.
|
175
|
+
#
|
176
|
+
# @param [Array<Field, Symbol>] columns
|
177
|
+
# The columns for `GROUP BY`.
|
178
|
+
#
|
179
|
+
# @return [self]
|
180
|
+
#
|
181
|
+
def group_by(*columns,&block)
|
182
|
+
clause([:GROUP, :BY],columns,&block)
|
183
|
+
end
|
184
|
+
|
185
|
+
#
|
186
|
+
# Appends a `HAVING` clause.
|
187
|
+
#
|
188
|
+
# @return [self]
|
189
|
+
#
|
190
|
+
def having(&block)
|
191
|
+
clause(:HAVING,&block)
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# Appends a `LIMIT` clause.
|
196
|
+
#
|
197
|
+
# @param [Integer] value
|
198
|
+
# The maximum number of rows to select.
|
199
|
+
#
|
200
|
+
# @return [self]
|
201
|
+
#
|
202
|
+
def limit(value,&block)
|
203
|
+
clause(:LIMIT,value,&block)
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# Appends a `OFFSET` clause.
|
208
|
+
#
|
209
|
+
# @param [Integer] value
|
210
|
+
# The index to start selecting at within the result set.
|
211
|
+
#
|
212
|
+
# @return [self]
|
213
|
+
#
|
214
|
+
def offset(value,&block)
|
215
|
+
clause(:OFFSET,value,&block)
|
216
|
+
end
|
217
|
+
|
218
|
+
#
|
219
|
+
# Appends a `TOP` clause.
|
220
|
+
#
|
221
|
+
# @param [Integer] value
|
222
|
+
# The number of top rows to select.
|
223
|
+
#
|
224
|
+
# @return [self]
|
225
|
+
#
|
226
|
+
def top(value,&block)
|
227
|
+
clause(:TOP,value,&block)
|
228
|
+
end
|
229
|
+
|
230
|
+
#
|
231
|
+
# Appends a `INTO` clause.
|
232
|
+
#
|
233
|
+
# @param [Field, Symbol] table
|
234
|
+
# The table to insert/replace into.
|
235
|
+
#
|
236
|
+
# @return [self]
|
237
|
+
#
|
238
|
+
def into(table)
|
239
|
+
clause(:INTO,table)
|
240
|
+
end
|
241
|
+
|
242
|
+
#
|
243
|
+
# Appends a `VALUES` clause.
|
244
|
+
#
|
245
|
+
# @param [Array] values
|
246
|
+
# The values to insert.
|
247
|
+
#
|
248
|
+
# @return [self]
|
249
|
+
#
|
250
|
+
def values(*values)
|
251
|
+
clause(:VALUES,values)
|
252
|
+
end
|
253
|
+
|
254
|
+
#
|
255
|
+
# Appends a `DEFAULT VALUES` clause.
|
256
|
+
#
|
257
|
+
# @return [self]
|
258
|
+
#
|
259
|
+
def default_values
|
260
|
+
clause([:DEFAULT, :VALUES])
|
261
|
+
end
|
262
|
+
|
263
|
+
#
|
264
|
+
# Appends a `SET` clause.
|
265
|
+
#
|
266
|
+
# @param [Hash{Field,Symbol => Object}] values
|
267
|
+
# The columns and values to update.
|
268
|
+
#
|
269
|
+
# @return [self]
|
270
|
+
#
|
271
|
+
def set(values={})
|
272
|
+
clause(:SET,values)
|
273
|
+
end
|
274
|
+
|
275
|
+
#
|
276
|
+
# Appends a `INDEXED BY` clause.
|
277
|
+
#
|
278
|
+
# @param [Field, Symbol] name
|
279
|
+
# The name of the index.
|
280
|
+
#
|
281
|
+
# @return [self]
|
282
|
+
#
|
283
|
+
def indexed_by(name,&block)
|
284
|
+
clause([:INDEXED, :BY],name,&block)
|
285
|
+
end
|
286
|
+
|
287
|
+
#
|
288
|
+
# Appends a `NOT INDEXED` clause.
|
289
|
+
#
|
290
|
+
# @return [self]
|
291
|
+
#
|
292
|
+
def not_indexed
|
293
|
+
clause([:NOT, :INDEXED])
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|