fluent-query-postgresql 0.9.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/.document +5 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +20 -0
- data/README.md +32 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/fluent-query-postgresql.gemspec +63 -0
- data/lib/fluent-query/drivers/postgresql.rb +112 -0
- data/lib/fluent-query/postgresql.rb +2 -0
- metadata +132 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
gem "fluent-query-dbi", ">= 0.9.0"
|
5
|
+
gem "fluent-query-sql", ">= 0.9.0"
|
6
|
+
gem "fluent-query", ">= 0.9.0"
|
7
|
+
gem "dbd-pg", ">= 0"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "bundler", "~> 1.0.13"
|
13
|
+
gem "jeweler", "~> 1.6.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# fluent-query-sql
|
19
|
+
# fluent-query-dbh
|
20
|
+
# fluent-query-mysql
|
21
|
+
# fluent-query-sqlite
|
22
|
+
# fluent-query-postgresql
|
23
|
+
# native-query
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
dbd-pg (0.3.9)
|
6
|
+
dbi (>= 0.4.0)
|
7
|
+
pg
|
8
|
+
dbi (0.4.5)
|
9
|
+
deprecated (= 2.0.1)
|
10
|
+
deprecated (2.0.1)
|
11
|
+
fluent-query (0.9.0)
|
12
|
+
abstract (>= 1.0.0)
|
13
|
+
hash-utils (>= 0.18.0)
|
14
|
+
hashie (>= 1.0.0)
|
15
|
+
fluent-query-dbi (0.9.0)
|
16
|
+
abstract (>= 1.0.0)
|
17
|
+
fluent-query (>= 0.9.0)
|
18
|
+
fluent-query-sql (>= 0.9.0)
|
19
|
+
hash-utils (>= 0.18.0)
|
20
|
+
fluent-query-sql (0.9.0)
|
21
|
+
abstract (>= 1.0.0)
|
22
|
+
fluent-query (>= 0.9.0)
|
23
|
+
hash-utils (>= 0.18.0)
|
24
|
+
git (1.2.5)
|
25
|
+
hash-utils (0.18.0)
|
26
|
+
hashie (1.0.0)
|
27
|
+
jeweler (1.6.3)
|
28
|
+
bundler (~> 1.0)
|
29
|
+
git (>= 1.2.5)
|
30
|
+
rake
|
31
|
+
pg (0.11.0)
|
32
|
+
rake (0.9.2)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.0.13)
|
39
|
+
dbd-pg
|
40
|
+
fluent-query (>= 0.9.0)
|
41
|
+
fluent-query-dbi (>= 0.9.0)
|
42
|
+
fluent-query-sql (>= 0.9.0)
|
43
|
+
jeweler (~> 1.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 - 2011 Martin Kozák (martinkozak@martinkozak.net)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Fluent Query PostgreSQL Driver
|
2
|
+
==============================
|
3
|
+
|
4
|
+
**Fluent Query** is cool way how to write SQL queries and general way
|
5
|
+
how to convert series of method calls to string query in an universal
|
6
|
+
and system independent manner.
|
7
|
+
|
8
|
+
This is **PostgreSQL** DBI based driver for *Fluent Query*. It can be
|
9
|
+
used with [Fluent Query][4] or [Native Query][5] only, not standalone.
|
10
|
+
|
11
|
+
|
12
|
+
Contributing
|
13
|
+
------------
|
14
|
+
|
15
|
+
1. Fork it.
|
16
|
+
2. Create a branch (`git checkout -b 20101220-my-change`).
|
17
|
+
3. Commit your changes (`git commit -am "Added something"`).
|
18
|
+
4. Push to the branch (`git push origin 20101220-my-change`).
|
19
|
+
5. Create an [Issue][2] with a link to your branch.
|
20
|
+
6. Enjoy a refreshing Diet Coke and wait.
|
21
|
+
|
22
|
+
Copyright
|
23
|
+
---------
|
24
|
+
|
25
|
+
Copyright © 2009-2011 [Martin Kozák][3]. See `LICENSE.txt` for
|
26
|
+
further details.
|
27
|
+
|
28
|
+
[2]: http://github.com/martinkozak/fluent-query-postgresql/issues
|
29
|
+
[3]: http://www.martinkozak.net/
|
30
|
+
[4]: http://github.com/martinkozak/fluent-query
|
31
|
+
[5]: http://github.com/martinkozak/native-query
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rake'
|
14
|
+
require 'jeweler'
|
15
|
+
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "fluent-query-postgresql"
|
19
|
+
gem.homepage = "http://github.com/martinkozak/fluent-query-postgresql"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = 'PostgreSQL support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby.'
|
22
|
+
gem.email = "martinkozak@martinkozak.net"
|
23
|
+
gem.authors = ["Martin Kozák"]
|
24
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
25
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
26
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
27
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.9.0
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{fluent-query-postgresql}
|
8
|
+
s.version = "0.9.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Martin Kozák}]
|
12
|
+
s.date = %q{2011-07-14}
|
13
|
+
s.email = %q{martinkozak@martinkozak.net}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE.txt",
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"fluent-query-postgresql.gemspec",
|
27
|
+
"lib/fluent-query/drivers/postgresql.rb",
|
28
|
+
"lib/fluent-query/postgresql.rb"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/martinkozak/fluent-query-postgresql}
|
31
|
+
s.licenses = [%q{MIT}]
|
32
|
+
s.require_paths = [%q{lib}]
|
33
|
+
s.rubygems_version = %q{1.8.5}
|
34
|
+
s.summary = %q{PostgreSQL support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby.}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_runtime_dependency(%q<fluent-query-dbi>, [">= 0.9.0"])
|
41
|
+
s.add_runtime_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
|
42
|
+
s.add_runtime_dependency(%q<fluent-query>, [">= 0.9.0"])
|
43
|
+
s.add_runtime_dependency(%q<dbd-pg>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.13"])
|
45
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<fluent-query-dbi>, [">= 0.9.0"])
|
48
|
+
s.add_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
|
49
|
+
s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
|
50
|
+
s.add_dependency(%q<dbd-pg>, [">= 0"])
|
51
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.13"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<fluent-query-dbi>, [">= 0.9.0"])
|
56
|
+
s.add_dependency(%q<fluent-query-sql>, [">= 0.9.0"])
|
57
|
+
s.add_dependency(%q<fluent-query>, [">= 0.9.0"])
|
58
|
+
s.add_dependency(%q<dbd-pg>, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.13"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "fluent-query/drivers/dbi"
|
3
|
+
require "fluent-query/drivers/exception"
|
4
|
+
require "fluent-query/drivers/shared/tokens/sql"
|
5
|
+
|
6
|
+
module FluentQuery
|
7
|
+
module Drivers
|
8
|
+
|
9
|
+
##
|
10
|
+
# PostgreSQL database driver.
|
11
|
+
#
|
12
|
+
|
13
|
+
class PostgreSQL < FluentQuery::Drivers::DBI
|
14
|
+
|
15
|
+
##
|
16
|
+
# Known tokens index.
|
17
|
+
# (internal cache)
|
18
|
+
#
|
19
|
+
|
20
|
+
@@__known_tokens = Hash::new do |hash, key|
|
21
|
+
hash[key] = { }
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Indicates token is known.
|
26
|
+
#
|
27
|
+
|
28
|
+
public
|
29
|
+
def known_token?(group, token_name)
|
30
|
+
super(group, token_name, @@__known_tokens)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
##### QUOTING
|
35
|
+
|
36
|
+
##
|
37
|
+
# Quotes string.
|
38
|
+
#
|
39
|
+
|
40
|
+
public
|
41
|
+
def quote_string(string)
|
42
|
+
"E" << super(string)
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Quotes system-dependent boolean value.
|
47
|
+
#
|
48
|
+
|
49
|
+
public
|
50
|
+
def quote_boolean(boolean)
|
51
|
+
boolean ? "TRUE" : "FALSE"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
##### EXECUTING
|
56
|
+
|
57
|
+
##
|
58
|
+
# Returns the DBI driver name.
|
59
|
+
# @return [String] driver name
|
60
|
+
#
|
61
|
+
|
62
|
+
public
|
63
|
+
def driver_name
|
64
|
+
"Pg"
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Opens the connection.
|
69
|
+
#
|
70
|
+
# It's lazy, so it will open connection before first request through
|
71
|
+
# {@link native_connection()} method.
|
72
|
+
#
|
73
|
+
|
74
|
+
public
|
75
|
+
def open_connection(settings)
|
76
|
+
if not settings[:database] or not settings[:username]
|
77
|
+
raise FluentQuery::Drivers::Exception::new("Database name and username is required for connection.")
|
78
|
+
end
|
79
|
+
|
80
|
+
super(settings)
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Returns native connection.
|
85
|
+
#
|
86
|
+
|
87
|
+
public
|
88
|
+
def native_connection
|
89
|
+
|
90
|
+
super()
|
91
|
+
|
92
|
+
# Gets settings
|
93
|
+
encoding, schema = @_nconnection_settings.take_values(:encoding, :schema)
|
94
|
+
|
95
|
+
if encoding.nil?
|
96
|
+
encoding = "UTF8"
|
97
|
+
end
|
98
|
+
|
99
|
+
# Sets encoding and default schema
|
100
|
+
@_nconnection.do("SET NAMES " << self.quote_string(encoding) << ";")
|
101
|
+
|
102
|
+
if not schema.nil?
|
103
|
+
@_nconnection.do("SET search_path = " << schema << ", pg_catalog;")
|
104
|
+
end
|
105
|
+
|
106
|
+
return @_nconnection
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-query-postgresql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.9.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- "Martin Koz\xC3\xA1k"
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-14 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fluent-query-dbi
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: fluent-query-sql
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: fluent-query
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.9.0
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: dbd-pg
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: bundler
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.0.13
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: jeweler
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.6.0
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *id006
|
81
|
+
description:
|
82
|
+
email: martinkozak@martinkozak.net
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- .document
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- VERSION
|
98
|
+
- fluent-query-postgresql.gemspec
|
99
|
+
- lib/fluent-query/drivers/postgresql.rb
|
100
|
+
- lib/fluent-query/postgresql.rb
|
101
|
+
homepage: http://github.com/martinkozak/fluent-query-postgresql
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 1993060455557468830
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.8.5
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: PostgreSQL support for the Fluent Query. Fluent Query is cool way how to write SQL queries in Ruby.
|
131
|
+
test_files: []
|
132
|
+
|