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.
Files changed (68) hide show
  1. data/CHANGELOG +116 -0
  2. data/COPYING +19 -19
  3. data/README +83 -32
  4. data/Rakefile +9 -20
  5. data/bin/sequel +43 -112
  6. data/doc/cheat_sheet.rdoc +225 -0
  7. data/doc/dataset_filtering.rdoc +257 -0
  8. data/lib/sequel_core/adapters/adapter_skeleton.rb +4 -2
  9. data/lib/sequel_core/adapters/ado.rb +3 -1
  10. data/lib/sequel_core/adapters/db2.rb +4 -2
  11. data/lib/sequel_core/adapters/dbi.rb +127 -113
  12. data/lib/sequel_core/adapters/informix.rb +4 -2
  13. data/lib/sequel_core/adapters/jdbc.rb +5 -3
  14. data/lib/sequel_core/adapters/mysql.rb +112 -46
  15. data/lib/sequel_core/adapters/odbc.rb +5 -7
  16. data/lib/sequel_core/adapters/odbc_mssql.rb +12 -3
  17. data/lib/sequel_core/adapters/openbase.rb +3 -1
  18. data/lib/sequel_core/adapters/oracle.rb +11 -9
  19. data/lib/sequel_core/adapters/postgres.rb +261 -262
  20. data/lib/sequel_core/adapters/sqlite.rb +72 -22
  21. data/lib/sequel_core/connection_pool.rb +140 -73
  22. data/lib/sequel_core/core_ext.rb +201 -66
  23. data/lib/sequel_core/core_sql.rb +123 -153
  24. data/lib/sequel_core/database/schema.rb +156 -0
  25. data/lib/sequel_core/database.rb +321 -338
  26. data/lib/sequel_core/dataset/callback.rb +11 -12
  27. data/lib/sequel_core/dataset/convenience.rb +213 -240
  28. data/lib/sequel_core/dataset/pagination.rb +58 -43
  29. data/lib/sequel_core/dataset/parse_tree_sequelizer.rb +331 -0
  30. data/lib/sequel_core/dataset/query.rb +41 -0
  31. data/lib/sequel_core/dataset/schema.rb +15 -0
  32. data/lib/sequel_core/dataset/sequelizer.rb +41 -373
  33. data/lib/sequel_core/dataset/sql.rb +741 -632
  34. data/lib/sequel_core/dataset.rb +183 -168
  35. data/lib/sequel_core/deprecated.rb +1 -169
  36. data/lib/sequel_core/exceptions.rb +24 -19
  37. data/lib/sequel_core/migration.rb +44 -52
  38. data/lib/sequel_core/object_graph.rb +43 -42
  39. data/lib/sequel_core/pretty_table.rb +71 -76
  40. data/lib/sequel_core/schema/generator.rb +163 -105
  41. data/lib/sequel_core/schema/sql.rb +250 -93
  42. data/lib/sequel_core/schema.rb +2 -8
  43. data/lib/sequel_core/sql.rb +394 -0
  44. data/lib/sequel_core/worker.rb +37 -27
  45. data/lib/sequel_core.rb +99 -45
  46. data/spec/adapters/informix_spec.rb +0 -1
  47. data/spec/adapters/mysql_spec.rb +177 -124
  48. data/spec/adapters/oracle_spec.rb +0 -1
  49. data/spec/adapters/postgres_spec.rb +98 -58
  50. data/spec/adapters/sqlite_spec.rb +45 -4
  51. data/spec/blockless_filters_spec.rb +269 -0
  52. data/spec/connection_pool_spec.rb +21 -18
  53. data/spec/core_ext_spec.rb +169 -19
  54. data/spec/core_sql_spec.rb +56 -49
  55. data/spec/database_spec.rb +78 -17
  56. data/spec/dataset_spec.rb +300 -428
  57. data/spec/migration_spec.rb +1 -1
  58. data/spec/object_graph_spec.rb +5 -11
  59. data/spec/rcov.opts +1 -1
  60. data/spec/schema_generator_spec.rb +16 -4
  61. data/spec/schema_spec.rb +89 -10
  62. data/spec/sequelizer_spec.rb +56 -56
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_config.rb +7 -0
  65. data/spec/spec_config.rb.example +5 -5
  66. data/spec/spec_helper.rb +6 -0
  67. data/spec/worker_spec.rb +1 -1
  68. metadata +78 -63
@@ -24,7 +24,7 @@ module Sequel
24
24
  end
25
25
 
26
26
  def execute(sql)
27
- @logger.info(sql) if @logger
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
- @logger.info(sql) if @logger
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
- result = yield(conn)
63
- conn.commit
64
- result
62
+ yield(conn)
65
63
  rescue => e
66
64
  conn.rollback
67
- raise e unless SequelRollbackError === e
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 Time
80
- literal(v.iso8601)
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]