perpetuity-postgres 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1674c0daefbd7dcfaad9351b6e653f22b0ade171
4
- data.tar.gz: b2b4e9059b515c61f3bfa0bcfda1f460c167cc51
3
+ metadata.gz: 84195d183dd75f856a69ea888e133407ab33596c
4
+ data.tar.gz: a08c32b762b10d9d33b26b099703b6521af12930
5
5
  SHA512:
6
- metadata.gz: f142288f17ca1ac7ad7b6a9c3f8e874e64276cb2a40d08b6f03c6733d1357763a2d97c95f56a3df3ffcea98106530bceb60f721277c32a81daffbe7baeb6ef77
7
- data.tar.gz: b624021e54ec0dc4632eb51b5ed56b56fe965fe63f7d559333da4b4f5260dc55b5907bccca3b0efbd3fe7070130e16d01cf0bf7409fdbe4f3eac8500a321609b
6
+ metadata.gz: 58737d3a8d9f9a7e462037189df2d8c500367f59b7f2d5505d22cb25bc2060f7557e6208bf4ef79f392660e842989c2c97a2ac49456885a4c7dce113458d41ec
7
+ data.tar.gz: c39806552ea5979a1902f0a9eaec465e5d65f4bfa0e0690aee06fcf5f84572c3a695d8b18d06d53235cf13616d2b007576d80eb002bb9ea08496eb6df491ee0c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Version 0.0.4
2
+
3
+ - Set minimum logging from the database to warnings. This silences info messages like those from `DROP TABLE IF NOT EXISTS ...` when the table doesn't exist.
4
+ - Add the ability to query on ids for objects. For example: `mapper.select { |article| article.author.id == params[:author_id] }`
5
+
1
6
  ## Version 0.0.3
2
7
 
3
8
  - Require the `bigdecimal` library to avoid undefined constant error: BigDecimals are converted to the Postgres `numeric` data type. In 1.9, it needs to be required explicitly. — [Avdi Grimm](https://github.com/avdi)
@@ -19,6 +19,8 @@ module Perpetuity
19
19
 
20
20
  def connect
21
21
  @pg_connection = PG.connect(options)
22
+ @pg_connection.exec 'SET client_min_messages TO warning'
23
+ @pg_connection
22
24
  rescue PG::ConnectionBad => e
23
25
  tries ||= 0
24
26
  connect_options = options.dup
@@ -38,6 +38,10 @@ METHOD
38
38
  QueryExpression.new count, :==, 0
39
39
  end
40
40
 
41
+ def id
42
+ QueryAttribute.new "#{name}->'__metadata__'->>'id'"
43
+ end
44
+
41
45
  def to_s
42
46
  name.to_s
43
47
  end
@@ -14,6 +14,10 @@ module Perpetuity
14
14
  def embedded?
15
15
  attribute.embedded?
16
16
  end
17
+
18
+ def method_missing *args, &block
19
+ value.send(*args, &block)
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  module Perpetuity
2
2
  class Postgres
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rspec"
23
23
  spec.add_development_dependency "rake"
24
- spec.add_runtime_dependency "perpetuity", "~> 1.0.0.beta2"
24
+ spec.add_runtime_dependency "perpetuity", "~> 1.0.0.beta5"
25
25
  spec.add_runtime_dependency "pg"
26
26
  end
@@ -15,7 +15,7 @@ module Perpetuity
15
15
 
16
16
  it 'is only activated when it is used' do
17
17
  connection.should_not be_active
18
- PG.stub(connect: true)
18
+ PG.stub(connect: double(exec: true))
19
19
  connection.connect
20
20
  connection.should be_active
21
21
  end
@@ -55,6 +55,14 @@ module Perpetuity
55
55
  it 'checks for truthiness' do
56
56
  attribute.to_db.should == 'attribute_name IS NOT NULL'
57
57
  end
58
+
59
+ describe 'nested attributes' do
60
+ it 'checks for an id' do
61
+ id = attribute.id
62
+ id.should be_a QueryAttribute
63
+ id.name.should == %q{attribute_name->'__metadata__'->>'id'}
64
+ end
65
+ end
58
66
  end
59
67
  end
60
68
  end
@@ -1,4 +1,5 @@
1
1
  require 'perpetuity/postgres/value_with_attribute'
2
+ require 'ostruct'
2
3
 
3
4
  module Perpetuity
4
5
  class Postgres
@@ -29,6 +30,10 @@ module Perpetuity
29
30
  serialized.should_not be_embedded
30
31
  end
31
32
  end
33
+
34
+ it 'passes messages to the value' do
35
+ serialized.upcase.should == 'FOO'
36
+ end
32
37
  end
33
38
  end
34
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perpetuity-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-19 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.0.beta2
61
+ version: 1.0.0.beta5
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.0.beta2
68
+ version: 1.0.0.beta5
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pg
71
71
  requirement: !ruby/object:Gem::Requirement