Class: FluentQuery::Drivers::PostgreSQL
- Inherits:
-
DBI
- Object
- DBI
- FluentQuery::Drivers::PostgreSQL
- Defined in:
- lib/fluent-query/drivers/postgresql.rb
Overview
PostgreSQL database driver.
Constant Summary collapse
- @@__known_tokens =
Known tokens index. (internal cache)
Hash::new do |hash, key| hash[key] = { } end
Instance Method Summary collapse
- #driver_name ⇒ Object
- #known_token?(group, token_name) ⇒ Boolean
- #native_connection ⇒ Object
- #open_connection(settings) ⇒ Object
- #quote_boolean(boolean) ⇒ Object
- #quote_string(string) ⇒ Object
Instance Method Details
#driver_name ⇒ Object
63 64 65 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 63 def driver_name "Pg" end |
#known_token?(group, token_name) ⇒ Boolean
29 30 31 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 29 def known_token?(group, token_name) super(group, token_name, @@__known_tokens) end |
#native_connection ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 88 def native_connection super() # Gets settings encoding, schema = @_nconnection_settings.take_values(:encoding, :schema) if encoding.nil? encoding = "UTF8" end # Sets encoding and default schema @_nconnection.do("SET NAMES " << self.quote_string(encoding) << ";") if not schema.nil? @_nconnection.do("SET search_path = " << self.quote_identifier(schema) << ", pg_catalog;") end return @_nconnection end |
#open_connection(settings) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 75 def open_connection(settings) if not settings[:database] or not settings[:username] raise FluentQuery::Drivers::Exception::new("Database name and username is required for connection.") end super(settings) end |
#quote_boolean(boolean) ⇒ Object
50 51 52 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 50 def quote_boolean(boolean) boolean ? "TRUE" : "FALSE" end |
#quote_string(string) ⇒ Object
41 42 43 |
# File 'lib/fluent-query/drivers/postgresql.rb', line 41 def quote_string(string) "E" << super(string) end |