rdo-postgres 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +11 -0
- data/README.md +2 -0
- data/ext/rdo_postgres/driver.c +1 -2
- data/lib/rdo/postgres.rb +2 -2
- data/lib/rdo/postgres/version.rb +1 -1
- data/rdo-postgres.gemspec +1 -1
- data/spec/postgres/bind_params_spec.rb +9 -25
- data/spec/postgres/type_cast_spec.rb +6 -5
- metadata +7 -6
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
language: ruby
|
2
|
+
services: postgresql
|
3
|
+
before_script:
|
4
|
+
- psql -c "CREATE USER rdo WITH PASSWORD 'rdo';" -U postgres
|
5
|
+
- psql -c "CREATE DATABASE rdo WITH OWNER rdo;" -U postgres
|
6
|
+
script: "CONNECTION=postgres://rdo:rdo@127.0.0.1/rdo?encoding=utf-8 bundle exec rake spec"
|
7
|
+
rvm:
|
8
|
+
- 1.9.2
|
9
|
+
- 1.9.3
|
10
|
+
notifications:
|
11
|
+
email: chris@w3style.co.uk
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
This is the PostgreSQL driver for [RDO—Ruby Data Objects]
|
4
4
|
(https://github.com/d11wtq/rdo).
|
5
5
|
|
6
|
+
[![Build Status](https://secure.travis-ci.org/d11wtq/rdo-postgres.png?branch=master)](http://travis-ci.org/d11wtq/rdo-postgres)
|
7
|
+
|
6
8
|
Refer to the RDO project [README](https://github.com/d11wtq/rdo) for usage
|
7
9
|
information.
|
8
10
|
|
data/ext/rdo_postgres/driver.c
CHANGED
@@ -105,8 +105,7 @@ static VALUE rdo_postgres_driver_prepare(VALUE self, VALUE cmd) {
|
|
105
105
|
char name[32];
|
106
106
|
sprintf(name, "rdo_stmt_%i", ++driver->stmt_count);
|
107
107
|
|
108
|
-
return
|
109
|
-
self, cmd, rb_str_new2(name)));
|
108
|
+
return rdo_postgres_statement_executor_new(self, cmd, rb_str_new2(name));
|
110
109
|
}
|
111
110
|
|
112
111
|
/** Quote a string literal for safe insertion in a statement */
|
data/lib/rdo/postgres.rb
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
require "rdo"
|
9
9
|
require "rdo/postgres/version"
|
10
10
|
require "rdo/postgres/driver"
|
11
|
-
|
12
|
-
#
|
11
|
+
|
12
|
+
# c extension
|
13
13
|
require "rdo_postgres/rdo_postgres"
|
14
14
|
|
15
15
|
# Register name variants for postgresql schemes
|
data/lib/rdo/postgres/version.rb
CHANGED
data/rdo-postgres.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = RDO::Postgres::VERSION
|
17
17
|
gem.extensions = ["ext/rdo_postgres/extconf.rb"]
|
18
18
|
|
19
|
-
gem.add_runtime_dependency "rdo", "
|
19
|
+
gem.add_runtime_dependency "rdo", "~> 0.1"
|
20
20
|
|
21
21
|
gem.add_development_dependency "rspec"
|
22
22
|
gem.add_development_dependency "rake-compiler"
|
@@ -472,31 +472,15 @@ describe RDO::Postgres::Driver, "bind parameter support" do
|
|
472
472
|
|
473
473
|
context "against a timestamptz field" do
|
474
474
|
let(:table) { "CREATE TABLE test (id serial primary key, created_at timestamptz)" }
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
Time.new(2012, 9, 22, 5, 16, 58)
|
481
|
-
).first
|
482
|
-
end
|
483
|
-
|
484
|
-
it "is inferred correctly" do
|
485
|
-
tuple.should == {id: 1, created_at: DateTime.new(2012, 9, 22, 5, 16, 58, DateTime.now.zone)}
|
486
|
-
end
|
475
|
+
let(:tuple) do
|
476
|
+
connection.execute(
|
477
|
+
"INSERT INTO test (created_at) VALUES (?) RETURNING *",
|
478
|
+
Time.new(2012, 9, 22, 5, 16, 58, "-07:00")
|
479
|
+
).first
|
487
480
|
end
|
488
481
|
|
489
|
-
|
490
|
-
|
491
|
-
connection.execute(
|
492
|
-
"INSERT INTO test (created_at) VALUES (?) RETURNING *",
|
493
|
-
Time.new(2012, 9, 22, 5, 16, 58, "-07:00")
|
494
|
-
).first
|
495
|
-
end
|
496
|
-
|
497
|
-
it "is inferred correctly" do
|
498
|
-
tuple.should == {id: 1, created_at: DateTime.new(2012, 9, 22, 5, 16, 58, "-07:00")}
|
499
|
-
end
|
482
|
+
it "is inferred correctly" do
|
483
|
+
tuple.should == {id: 1, created_at: DateTime.new(2012, 9, 22, 5, 16, 58, "-07:00")}
|
500
484
|
end
|
501
485
|
end
|
502
486
|
|
@@ -732,7 +716,7 @@ describe RDO::Postgres::Driver, "bind parameter support" do
|
|
732
716
|
end
|
733
717
|
|
734
718
|
let(:tuple) do
|
735
|
-
connection.execute(<<-SQL, "bob", 17, false, Time.new(2012, 9, 22, 6, 34)).first
|
719
|
+
connection.execute(<<-SQL, "bob", 17, false, Time.new(2012, 9, 22, 6, 34, 0, "-07:00")).first
|
736
720
|
INSERT INTO test (
|
737
721
|
name, age, admin, created_at
|
738
722
|
) VALUES (
|
@@ -747,7 +731,7 @@ describe RDO::Postgres::Driver, "bind parameter support" do
|
|
747
731
|
name: "bob",
|
748
732
|
age: 17,
|
749
733
|
admin: false,
|
750
|
-
created_at: DateTime.new(2012, 9, 22, 6, 34, 0,
|
734
|
+
created_at: DateTime.new(2012, 9, 22, 6, 34, 0, "-07:00")
|
751
735
|
}
|
752
736
|
end
|
753
737
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "rational"
|
2
3
|
|
3
4
|
describe RDO::Postgres::Driver, "type casting" do
|
4
5
|
let(:options) { connection_uri }
|
@@ -248,15 +249,15 @@ describe RDO::Postgres::Driver, "type casting" do
|
|
248
249
|
context "with a time zone" do
|
249
250
|
let(:sql) { "SELECT '2012-09-22 04:26:34'::timestamptz" }
|
250
251
|
|
251
|
-
it "returns a DateTime, in the
|
252
|
+
it "returns a DateTime, in the system time zone" do
|
252
253
|
value.should == DateTime.new(2012, 9, 22, 4, 26, 34, DateTime.now.zone)
|
253
254
|
end
|
254
255
|
|
255
256
|
context "specifying an alternate time zone" do
|
256
|
-
let(:sql) { "SELECT '2012-09-22 04:26:34'::
|
257
|
+
let(:sql) { "SELECT '2012-09-22 04:26:34'::timestamp at time zone 'UTC'" }
|
257
258
|
|
258
|
-
it "returns a DateTime at the
|
259
|
-
value.should == DateTime.new(2012, 9,
|
259
|
+
it "returns a DateTime at the system time zone" do
|
260
|
+
value.should == DateTime.new(2012, 9, 22, 4, 26, 34, 0).new_offset(Time.now.utc_offset)
|
260
261
|
end
|
261
262
|
end
|
262
263
|
|
@@ -264,7 +265,7 @@ describe RDO::Postgres::Driver, "type casting" do
|
|
264
265
|
before(:each) { connection.execute("SET timezone = 'UTC'") }
|
265
266
|
|
266
267
|
it "returns a DateTime with the conversion done accordingly" do
|
267
|
-
value.should == DateTime.new(2012, 9, 22,
|
268
|
+
value.should == DateTime.new(2012, 9, 22, 4, 26, 34, 0)
|
268
269
|
end
|
269
270
|
end
|
270
271
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdo-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdo
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: '0.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: '0.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,6 +69,7 @@ extra_rdoc_files: []
|
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
71
|
- .rspec
|
72
|
+
- .travis.yml
|
72
73
|
- Gemfile
|
73
74
|
- LICENSE
|
74
75
|
- README.md
|