sequel 2.3.0 → 2.4.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.
- data/CHANGELOG +16 -0
- data/README +4 -1
- data/Rakefile +17 -19
- data/doc/prepared_statements.rdoc +104 -0
- data/doc/sharding.rdoc +113 -0
- data/lib/sequel_core/adapters/ado.rb +24 -17
- data/lib/sequel_core/adapters/db2.rb +30 -33
- data/lib/sequel_core/adapters/dbi.rb +15 -13
- data/lib/sequel_core/adapters/informix.rb +13 -14
- data/lib/sequel_core/adapters/jdbc.rb +243 -60
- data/lib/sequel_core/adapters/jdbc/mysql.rb +32 -24
- data/lib/sequel_core/adapters/jdbc/postgresql.rb +32 -2
- data/lib/sequel_core/adapters/jdbc/sqlite.rb +16 -20
- data/lib/sequel_core/adapters/mysql.rb +164 -76
- data/lib/sequel_core/adapters/odbc.rb +21 -34
- data/lib/sequel_core/adapters/openbase.rb +10 -7
- data/lib/sequel_core/adapters/oracle.rb +17 -23
- data/lib/sequel_core/adapters/postgres.rb +246 -35
- data/lib/sequel_core/adapters/shared/mssql.rb +106 -0
- data/lib/sequel_core/adapters/shared/mysql.rb +34 -26
- data/lib/sequel_core/adapters/shared/postgres.rb +82 -38
- data/lib/sequel_core/adapters/shared/sqlite.rb +48 -16
- data/lib/sequel_core/adapters/sqlite.rb +141 -44
- data/lib/sequel_core/connection_pool.rb +85 -63
- data/lib/sequel_core/database.rb +46 -17
- data/lib/sequel_core/dataset.rb +21 -40
- data/lib/sequel_core/dataset/convenience.rb +3 -3
- data/lib/sequel_core/dataset/prepared_statements.rb +218 -0
- data/lib/sequel_core/exceptions.rb +0 -12
- data/lib/sequel_model/base.rb +1 -2
- data/lib/sequel_model/plugins.rb +1 -1
- data/spec/adapters/ado_spec.rb +32 -3
- data/spec/adapters/mysql_spec.rb +7 -8
- data/spec/integration/prepared_statement_test.rb +106 -0
- data/spec/sequel_core/connection_pool_spec.rb +105 -3
- data/spec/sequel_core/database_spec.rb +41 -3
- data/spec/sequel_core/dataset_spec.rb +117 -7
- data/spec/sequel_core/spec_helper.rb +2 -2
- data/spec/sequel_model/model_spec.rb +0 -6
- data/spec/sequel_model/spec_helper.rb +1 -1
- metadata +11 -6
- data/lib/sequel_core/adapters/adapter_skeleton.rb +0 -54
- data/lib/sequel_core/adapters/odbc_mssql.rb +0 -106
@@ -27,7 +27,7 @@ class MockDatabase < Sequel::Database
|
|
27
27
|
@@quote_identifiers = false
|
28
28
|
attr_reader :sqls
|
29
29
|
|
30
|
-
def execute(sql)
|
30
|
+
def execute(sql, opts={})
|
31
31
|
@sqls ||= []
|
32
32
|
@sqls << sql
|
33
33
|
end
|
@@ -44,7 +44,7 @@ end
|
|
44
44
|
class SchemaDummyDatabase < Sequel::Database
|
45
45
|
attr_reader :sqls
|
46
46
|
|
47
|
-
def execute(sql)
|
47
|
+
def execute(sql, opts={})
|
48
48
|
@sqls ||= []
|
49
49
|
@sqls << sql
|
50
50
|
end
|
@@ -519,12 +519,6 @@ describe Sequel::Model, ".[]" do
|
|
519
519
|
$sqls.last.should == "SELECT * FROM items WHERE (id = 9999) LIMIT 1"
|
520
520
|
end
|
521
521
|
|
522
|
-
it "should raise for boolean argument (mistaken comparison)" do
|
523
|
-
# This in order to prevent stuff like Model[:a == 'b']
|
524
|
-
proc {@c[:a == 1]}.should raise_error(Sequel::Error)
|
525
|
-
proc {@c[:a != 1]}.should raise_error(Sequel::Error)
|
526
|
-
end
|
527
|
-
|
528
522
|
it "should work correctly for custom primary key" do
|
529
523
|
@c.set_primary_key :name
|
530
524
|
@c['sharon'].should be_a_kind_of(@c)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,6 +26,8 @@ extra_rdoc_files:
|
|
26
26
|
- doc/advanced_associations.rdoc
|
27
27
|
- doc/cheat_sheet.rdoc
|
28
28
|
- doc/dataset_filtering.rdoc
|
29
|
+
- doc/prepared_statements.rdoc
|
30
|
+
- doc/sharding.rdoc
|
29
31
|
files:
|
30
32
|
- COPYING
|
31
33
|
- CHANGELOG
|
@@ -35,6 +37,8 @@ files:
|
|
35
37
|
- doc/advanced_associations.rdoc
|
36
38
|
- doc/cheat_sheet.rdoc
|
37
39
|
- doc/dataset_filtering.rdoc
|
40
|
+
- doc/prepared_statements.rdoc
|
41
|
+
- doc/sharding.rdoc
|
38
42
|
- spec/adapters
|
39
43
|
- spec/adapters/informix_spec.rb
|
40
44
|
- spec/adapters/mysql_spec.rb
|
@@ -81,11 +85,11 @@ files:
|
|
81
85
|
- spec/integration/dataset_test.rb
|
82
86
|
- spec/integration/schema_test.rb
|
83
87
|
- spec/integration/type_test.rb
|
88
|
+
- spec/integration/prepared_statement_test.rb
|
84
89
|
- lib/sequel.rb
|
85
90
|
- lib/sequel_core.rb
|
86
91
|
- lib/sequel_core
|
87
92
|
- lib/sequel_core/adapters
|
88
|
-
- lib/sequel_core/adapters/adapter_skeleton.rb
|
89
93
|
- lib/sequel_core/adapters/ado.rb
|
90
94
|
- lib/sequel_core/adapters/db2.rb
|
91
95
|
- lib/sequel_core/adapters/dbi.rb
|
@@ -93,18 +97,18 @@ files:
|
|
93
97
|
- lib/sequel_core/adapters/jdbc.rb
|
94
98
|
- lib/sequel_core/adapters/mysql.rb
|
95
99
|
- lib/sequel_core/adapters/odbc.rb
|
96
|
-
- lib/sequel_core/adapters/odbc_mssql.rb
|
97
100
|
- lib/sequel_core/adapters/openbase.rb
|
98
101
|
- lib/sequel_core/adapters/oracle.rb
|
99
102
|
- lib/sequel_core/adapters/postgres.rb
|
100
103
|
- lib/sequel_core/adapters/sqlite.rb
|
101
104
|
- lib/sequel_core/adapters/shared
|
105
|
+
- lib/sequel_core/adapters/shared/mysql.rb
|
106
|
+
- lib/sequel_core/adapters/shared/mssql.rb
|
102
107
|
- lib/sequel_core/adapters/shared/postgres.rb
|
103
108
|
- lib/sequel_core/adapters/shared/sqlite.rb
|
104
|
-
- lib/sequel_core/adapters/shared/mysql.rb
|
105
109
|
- lib/sequel_core/adapters/jdbc
|
106
|
-
- lib/sequel_core/adapters/jdbc/postgresql.rb
|
107
110
|
- lib/sequel_core/adapters/jdbc/mysql.rb
|
111
|
+
- lib/sequel_core/adapters/jdbc/postgresql.rb
|
108
112
|
- lib/sequel_core/adapters/jdbc/sqlite.rb
|
109
113
|
- lib/sequel_core/connection_pool.rb
|
110
114
|
- lib/sequel_core/core_ext.rb
|
@@ -120,6 +124,7 @@ files:
|
|
120
124
|
- lib/sequel_core/dataset/query.rb
|
121
125
|
- lib/sequel_core/dataset/schema.rb
|
122
126
|
- lib/sequel_core/dataset/sql.rb
|
127
|
+
- lib/sequel_core/dataset/prepared_statements.rb
|
123
128
|
- lib/sequel_core/deprecated.rb
|
124
129
|
- lib/sequel_core/exceptions.rb
|
125
130
|
- lib/sequel_core/migration.rb
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Sequel
|
2
|
-
module Adapter
|
3
|
-
class Database < Sequel::Database
|
4
|
-
set_adapter_scheme :adapter
|
5
|
-
|
6
|
-
def connect
|
7
|
-
AdapterDB.new(@opts[:database], @opts[:user], @opts[:password])
|
8
|
-
end
|
9
|
-
|
10
|
-
def disconnect
|
11
|
-
@pool.disconnect {|c| c.disconnect}
|
12
|
-
end
|
13
|
-
|
14
|
-
def dataset(opts = nil)
|
15
|
-
Adapter::Dataset.new(self, opts)
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute(sql)
|
19
|
-
log_info(sql)
|
20
|
-
@pool.hold {|conn| conn.exec(sql)}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Dataset < Sequel::Dataset
|
25
|
-
def literal(v)
|
26
|
-
case v
|
27
|
-
when Time
|
28
|
-
literal(v.iso8601)
|
29
|
-
when Date, DateTime
|
30
|
-
literal(v.to_s)
|
31
|
-
else
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def fetch_rows(sql, &block)
|
37
|
-
@db.synchronize do
|
38
|
-
cursor = @db.execute sql
|
39
|
-
begin
|
40
|
-
@columns = cursor.get_col_names.map {|c| c.to_sym}
|
41
|
-
while r = cursor.fetch
|
42
|
-
row = {}
|
43
|
-
r.each_with_index {|v, i| row[@columns[i]] = v}
|
44
|
-
yield row
|
45
|
-
end
|
46
|
-
ensure
|
47
|
-
cursor.close
|
48
|
-
end
|
49
|
-
end
|
50
|
-
self
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
if !Sequel.const_defined?('ODBC')
|
2
|
-
require File.join(File.dirname(__FILE__), 'odbc')
|
3
|
-
end
|
4
|
-
|
5
|
-
module Sequel
|
6
|
-
module ODBC
|
7
|
-
module MSSQL
|
8
|
-
class Database < ODBC::Database
|
9
|
-
set_adapter_scheme :odbc_mssql
|
10
|
-
|
11
|
-
def dataset(opts = nil)
|
12
|
-
MSSQL::Dataset.new(self, opts)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Dataset < ODBC::Dataset
|
17
|
-
# Allows you to do .nolock on a query
|
18
|
-
def nolock
|
19
|
-
clone(:with => "(NOLOCK)")
|
20
|
-
end
|
21
|
-
|
22
|
-
# Formats a SELECT statement using the given options and the dataset
|
23
|
-
# options.
|
24
|
-
def select_sql(opts = nil)
|
25
|
-
opts = opts ? @opts.merge(opts) : @opts
|
26
|
-
|
27
|
-
if sql = opts[:sql]
|
28
|
-
return sql
|
29
|
-
end
|
30
|
-
|
31
|
-
# ADD TOP to SELECT string for LIMITS
|
32
|
-
if limit = opts[:limit]
|
33
|
-
top = "TOP #{limit} "
|
34
|
-
raise Error, "Offset not supported" if opts[:offset]
|
35
|
-
end
|
36
|
-
|
37
|
-
columns = opts[:select]
|
38
|
-
select_columns = columns ? column_list(columns) : WILDCARD
|
39
|
-
|
40
|
-
if distinct = opts[:distinct]
|
41
|
-
distinct_clause = distinct.empty? ? "DISTINCT" : "DISTINCT ON (#{expression_list(distinct)})"
|
42
|
-
sql = "SELECT #{top}#{distinct_clause} #{select_columns}"
|
43
|
-
else
|
44
|
-
sql = "SELECT #{top}#{select_columns}"
|
45
|
-
end
|
46
|
-
|
47
|
-
if opts[:from]
|
48
|
-
sql << " FROM #{source_list(opts[:from])}"
|
49
|
-
end
|
50
|
-
|
51
|
-
# ADD WITH to SELECT string for NOLOCK
|
52
|
-
if with = opts[:with]
|
53
|
-
sql << " WITH #{with}"
|
54
|
-
end
|
55
|
-
|
56
|
-
if join = opts[:join]
|
57
|
-
join.each{|j| sql << literal(j)}
|
58
|
-
end
|
59
|
-
|
60
|
-
if where = opts[:where]
|
61
|
-
sql << " WHERE #{literal(where)}"
|
62
|
-
end
|
63
|
-
|
64
|
-
if group = opts[:group]
|
65
|
-
sql << " GROUP BY #{expression_list(group)}"
|
66
|
-
end
|
67
|
-
|
68
|
-
if order = opts[:order]
|
69
|
-
sql << " ORDER BY #{expression_list(order)}"
|
70
|
-
end
|
71
|
-
|
72
|
-
if having = opts[:having]
|
73
|
-
sql << " HAVING #{literal(having)}"
|
74
|
-
end
|
75
|
-
|
76
|
-
if union = opts[:union]
|
77
|
-
sql << (opts[:union_all] ? \
|
78
|
-
" UNION ALL #{union.sql}" : " UNION #{union.sql}")
|
79
|
-
elsif intersect = opts[:intersect]
|
80
|
-
sql << (opts[:intersect_all] ? \
|
81
|
-
" INTERSECT ALL #{intersect.sql}" : " INTERSECT #{intersect.sql}")
|
82
|
-
elsif except = opts[:except]
|
83
|
-
sql << (opts[:except_all] ? \
|
84
|
-
" EXCEPT ALL #{except.sql}" : " EXCEPT #{except.sql}")
|
85
|
-
end
|
86
|
-
|
87
|
-
sql
|
88
|
-
end
|
89
|
-
alias_method :sql, :select_sql
|
90
|
-
|
91
|
-
def full_text_search(cols, terms, opts = {})
|
92
|
-
filter("CONTAINS (#{literal(cols)}, #{literal(terms)})")
|
93
|
-
end
|
94
|
-
|
95
|
-
def complex_expression_sql(op, args)
|
96
|
-
case op
|
97
|
-
when :'||'
|
98
|
-
super(:+, args)
|
99
|
-
else
|
100
|
-
super(op, args)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|