class Pon::Adapter::Pg
- Pon::Adapter::Pg
- Pon::Adapter::RDB
- Pon::Adapter
- Reference
- Object
Overview
PostgreSQL implementation of the Adapter
Defined in:
pon/adapter/pg.crConstant Summary
-
BIND_TYPE =
BindType::Dollar
-
LAST_VAL =
"SELECT LASTVAL()"
-
QUOTE =
'"'
-
RawTypes =
{"AUTO_Int32" => "SERIAL PRIMARY KEY", "AUTO_Int64" => "BIGSERIAL PRIMARY KEY", "Time::Span" => "TIME", "created_at" => "TIMESTAMP", "updated_at" => "TIMESTAMP"}
-
SETTING =
"name = \"pg\"\n\nurl = \"postgres://postgres:@127.0.0.1:5432/postgres\"\ninit_pool_size = 1\nmax_pool_size = 5\n\n[query]\nshow_databases = \"\"\"\n SELECT datname\n FROM pg_database\n \"\"\"\n\nshow_tables = \"\"\"\n SELECT tablename\n FROM pg_catalog.pg_tables\n WHERE schemaname != 'pg_catalog'\n AND schemaname != 'information_schema'\n \"\"\""
Constructors
-
.new(klass, table_name : String, primary_name : String, setting : Pon::Setting | Nil = nil)
PostgreSQL implementation of the Adapter
Class Method Summary
-
.escape(name : String) : String
escapes the value by
QUOTE
-
.quote(name : String) : String
ensures the value is quoted with idempotency returns the value itself when it already contains
QUOTE
crystal quote("foo") # => "`foo`" quote("`foo`") # => "`foo`" quote("`foo`.bar") # => "`foo`.bar"
-
.raw_type?(key : String)
converts the crystal class to database type of this adapter
-
.setting
PostgreSQL implementation of the Adapter
Instance Method Summary
-
#all(fields : Array(String), types, query_string = nil, **opts)
PostgreSQL implementation of the Adapter
-
#all(fields : Array(String | Nil), types, query_string = nil, **opts)
PostgreSQL implementation of the Adapter
-
#count : Int32
PostgreSQL implementation of the Adapter
-
#database : DB::Database
#database
abstracts unique connections and access to shared connections. - #databases : Array(String)
-
#delete(key) : Nil
PostgreSQL implementation of the Adapter
-
#delete : Nil
PostgreSQL implementation of the Adapter
-
#exec(query : String, params = [] of String)
NOTE all "?" appeared in query part will be replaced when params exist
-
#insert(fields, params)
PostgreSQL implementation of the Adapter
-
#lastval : Int64
PostgreSQL implementation of the Adapter
-
#one?(id, fields : Array(String), as types : Tuple)
PostgreSQL implementation of the Adapter
-
#qp : String
PostgreSQL implementation of the Adapter
-
#qt : String
PostgreSQL implementation of the Adapter
-
#quote_field(name : String | Nil) : String
PostgreSQL implementation of the Adapter
-
#reset! : Nil
PostgreSQL implementation of the Adapter
-
#table_name : String
PostgreSQL implementation of the Adapter
-
#tables : Array(String)
PostgreSQL implementation of the Adapter
-
#transaction(&) : Nil
PostgreSQL implementation of the Adapter
-
#truncate : Nil
PostgreSQL implementation of the Adapter
-
#update(fields, params)
PostgreSQL implementation of the Adapter
Instance methods inherited from class Pon::Adapter::RDB
all(fields : Array(String), types, query_string = nil, **opts)
all,
count : Int32
count,
databases : Array(String)
databases,
delete(key) : Nildelete : Nil delete, exec(query : String, params = [] of String) exec, insert(fields, params) insert, lastval : Int64 lastval, one?(id, fields : Array(String), as types : Tuple) one?, query_all(*args, **options)
query_all(*args, **options, &) query_all, query_one?(*args, **options)
query_one?(*args, **options, &) query_one?, quote(*args, **options)
quote(*args, **options, &) quote, reset! : Nil reset!, scalar(*args, **options)
scalar(*args, **options, &) scalar, table_name : String table_name, tables : Array(String) tables, transaction(&) : Nil transaction, truncate : Nil truncate
Instance methods inherited from class Pon::Adapter
query_log(sql, group)
query_log
Class methods inherited from class Pon::Adapter
build_database(setting) : DB::Database
build_database,
database(setting : Setting) : DB::Database
database,
databases
databases,
reset!(setting : Setting) : Nilreset! : Nil reset!, settings settings
Constructor Detail
PostgreSQL implementation of the Adapter
Class Method Detail
ensures the value is quoted with idempotency
returns the value itself when it already contains QUOTE
quote("foo") # => "`foo`"
quote("`foo`") # => "`foo`"
quote("`foo`.bar") # => "`foo`.bar"
Instance Method Detail
PostgreSQL implementation of the Adapter
PostgreSQL implementation of the Adapter
#database
abstracts unique connections and access to shared connections.
Querying each time accessing without caching slightly degrades performance,
but this mechanism is required when resetting shared connections.
NOTE all "?" appeared in query part will be replaced when params exist