sequel_core 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +116 -0
- data/COPYING +19 -19
- data/README +83 -32
- data/Rakefile +9 -20
- data/bin/sequel +43 -112
- data/doc/cheat_sheet.rdoc +225 -0
- data/doc/dataset_filtering.rdoc +257 -0
- data/lib/sequel_core/adapters/adapter_skeleton.rb +4 -2
- data/lib/sequel_core/adapters/ado.rb +3 -1
- data/lib/sequel_core/adapters/db2.rb +4 -2
- data/lib/sequel_core/adapters/dbi.rb +127 -113
- data/lib/sequel_core/adapters/informix.rb +4 -2
- data/lib/sequel_core/adapters/jdbc.rb +5 -3
- data/lib/sequel_core/adapters/mysql.rb +112 -46
- data/lib/sequel_core/adapters/odbc.rb +5 -7
- data/lib/sequel_core/adapters/odbc_mssql.rb +12 -3
- data/lib/sequel_core/adapters/openbase.rb +3 -1
- data/lib/sequel_core/adapters/oracle.rb +11 -9
- data/lib/sequel_core/adapters/postgres.rb +261 -262
- data/lib/sequel_core/adapters/sqlite.rb +72 -22
- data/lib/sequel_core/connection_pool.rb +140 -73
- data/lib/sequel_core/core_ext.rb +201 -66
- data/lib/sequel_core/core_sql.rb +123 -153
- data/lib/sequel_core/database/schema.rb +156 -0
- data/lib/sequel_core/database.rb +321 -338
- data/lib/sequel_core/dataset/callback.rb +11 -12
- data/lib/sequel_core/dataset/convenience.rb +213 -240
- data/lib/sequel_core/dataset/pagination.rb +58 -43
- data/lib/sequel_core/dataset/parse_tree_sequelizer.rb +331 -0
- data/lib/sequel_core/dataset/query.rb +41 -0
- data/lib/sequel_core/dataset/schema.rb +15 -0
- data/lib/sequel_core/dataset/sequelizer.rb +41 -373
- data/lib/sequel_core/dataset/sql.rb +741 -632
- data/lib/sequel_core/dataset.rb +183 -168
- data/lib/sequel_core/deprecated.rb +1 -169
- data/lib/sequel_core/exceptions.rb +24 -19
- data/lib/sequel_core/migration.rb +44 -52
- data/lib/sequel_core/object_graph.rb +43 -42
- data/lib/sequel_core/pretty_table.rb +71 -76
- data/lib/sequel_core/schema/generator.rb +163 -105
- data/lib/sequel_core/schema/sql.rb +250 -93
- data/lib/sequel_core/schema.rb +2 -8
- data/lib/sequel_core/sql.rb +394 -0
- data/lib/sequel_core/worker.rb +37 -27
- data/lib/sequel_core.rb +99 -45
- data/spec/adapters/informix_spec.rb +0 -1
- data/spec/adapters/mysql_spec.rb +177 -124
- data/spec/adapters/oracle_spec.rb +0 -1
- data/spec/adapters/postgres_spec.rb +98 -58
- data/spec/adapters/sqlite_spec.rb +45 -4
- data/spec/blockless_filters_spec.rb +269 -0
- data/spec/connection_pool_spec.rb +21 -18
- data/spec/core_ext_spec.rb +169 -19
- data/spec/core_sql_spec.rb +56 -49
- data/spec/database_spec.rb +78 -17
- data/spec/dataset_spec.rb +300 -428
- data/spec/migration_spec.rb +1 -1
- data/spec/object_graph_spec.rb +5 -11
- data/spec/rcov.opts +1 -1
- data/spec/schema_generator_spec.rb +16 -4
- data/spec/schema_spec.rb +89 -10
- data/spec/sequelizer_spec.rb +56 -56
- data/spec/spec.opts +0 -5
- data/spec/spec_config.rb +7 -0
- data/spec/spec_config.rb.example +5 -5
- data/spec/spec_helper.rb +6 -0
- data/spec/worker_spec.rb +1 -1
- metadata +78 -63
@@ -24,7 +24,7 @@ module Sequel
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def execute(sql)
|
27
|
-
|
27
|
+
log_info(sql)
|
28
28
|
@pool.hold {|conn| conn.execute(sql)}
|
29
29
|
end
|
30
30
|
|
@@ -36,6 +36,8 @@ module Sequel
|
|
36
36
|
case v
|
37
37
|
when Time
|
38
38
|
literal(v.iso8601)
|
39
|
+
when Date, DateTime
|
40
|
+
literal(v.to_s)
|
39
41
|
else
|
40
42
|
super
|
41
43
|
end
|
@@ -33,7 +33,7 @@ module Sequel
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def execute(sql)
|
36
|
-
|
36
|
+
log_info(sql)
|
37
37
|
@pool.hold {|conn| conn.exec(sql)}
|
38
38
|
end
|
39
39
|
|
@@ -59,13 +59,12 @@ module Sequel
|
|
59
59
|
conn.autocommit = false
|
60
60
|
begin
|
61
61
|
@transactions << Thread.current
|
62
|
-
|
63
|
-
conn.commit
|
64
|
-
result
|
62
|
+
yield(conn)
|
65
63
|
rescue => e
|
66
64
|
conn.rollback
|
67
|
-
raise e unless
|
65
|
+
raise e unless Error::Rollback === e
|
68
66
|
ensure
|
67
|
+
conn.commit unless e
|
69
68
|
conn.autocommit = true
|
70
69
|
@transactions.delete(Thread.current)
|
71
70
|
end
|
@@ -76,8 +75,8 @@ module Sequel
|
|
76
75
|
class Dataset < Sequel::Dataset
|
77
76
|
def literal(v)
|
78
77
|
case v
|
79
|
-
when
|
80
|
-
literal(v.
|
78
|
+
when OraDate
|
79
|
+
literal(Time.local(*v.to_a))
|
81
80
|
else
|
82
81
|
super
|
83
82
|
end
|
@@ -112,6 +111,9 @@ module Sequel
|
|
112
111
|
@db.do delete_sql(opts)
|
113
112
|
end
|
114
113
|
|
114
|
+
def empty?
|
115
|
+
db[:dual].where(exists).get(1) == nil
|
116
|
+
end
|
115
117
|
|
116
118
|
# Formats a SELECT statement using the given options and the dataset
|
117
119
|
# options.
|
@@ -137,7 +139,7 @@ module Sequel
|
|
137
139
|
end
|
138
140
|
|
139
141
|
if where = opts[:where]
|
140
|
-
sql << " WHERE #{where}"
|
142
|
+
sql << " WHERE #{literal(where)}"
|
141
143
|
end
|
142
144
|
|
143
145
|
if group = opts[:group]
|
@@ -145,7 +147,7 @@ module Sequel
|
|
145
147
|
end
|
146
148
|
|
147
149
|
if having = opts[:having]
|
148
|
-
sql << " HAVING #{having}"
|
150
|
+
sql << " HAVING #{literal(having)}"
|
149
151
|
end
|
150
152
|
|
151
153
|
if union = opts[:union]
|