Class | PGconn |
In: |
lib/sequel/adapters/postgres.rb
|
Parent: | Object |
Attempt to get uniform behavior for the PGconn object no matter if pg, postgres, or postgres-pr is used.
CONNECTION_OK | = | -1 |
decode_bytea | -> | unescape_bytea |
close | -> | finish |
exec | -> | async_exec |
If no valid bytea unescaping method can be found, create one that raises an error
# File lib/sequel/adapters/postgres.rb, line 63 63: def self.unescape_bytea(obj) 64: raise Sequel::Error, "bytea unescaping not supported with this postgres driver. Try using ruby-pg, ruby-postgres, or postgres-pr." 65: end
If there is no escape_bytea instance method, but there is an escape_bytea class method, use that instead.
# File lib/sequel/adapters/postgres.rb, line 41 41: def escape_bytea(obj) 42: self.class.escape_bytea(obj) 43: end
If no valid bytea escaping method can be found, create one that raises an error
# File lib/sequel/adapters/postgres.rb, line 58 58: def escape_bytea(obj) 59: raise Sequel::Error, "bytea escaping not supported with this postgres driver. Try using ruby-pg, ruby-postgres, or postgres-pr." 60: end
If we are using postgres-pr, use the encode_bytea method from that.
# File lib/sequel/adapters/postgres.rb, line 51 51: def escape_bytea(obj) 52: self.class.encode_bytea(obj) 53: end
If there is no escape_string instance method, but there is an escape class method, use that instead.
# File lib/sequel/adapters/postgres.rb, line 23 23: def escape_string(str) 24: Sequel::Postgres.force_standard_strings ? str.gsub("'", "''") : self.class.escape(str) 25: end
Raise an error if no valid string escaping method can be found.
# File lib/sequel/adapters/postgres.rb, line 28 28: def escape_string(obj) 29: if Sequel::Postgres.force_standard_strings 30: str.gsub("'", "''") 31: else 32: raise Sequel::Error, "string escaping not supported with this postgres driver. Try using ruby-pg, ruby-postgres, or postgres-pr." 33: end 34: end