Class: ActiveRecord::ConnectionAdapters::PGliteAdapter

Inherits:
PostgreSQLAdapter
  • Object
show all
Defined in:
lib/active_record/connection_adapters/pglite_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePGliteAdapter

Returns a new instance of PGliteAdapter.



41
42
43
44
45
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 41

def initialize(...)
  super
  # Prepared statements are not currently supported
  @prepared_statements = false
end

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 34

def database_exists?(config)
  true
end

.new_clientObject



38
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 38

def new_client(...) = PGlite::Connection.new(...)

Instance Method Details

#add_pg_decodersObject



50
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 50

def add_pg_decoders = nil

#add_pg_encodersObject

Stub encoders/decoders



48
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 48

def add_pg_encoders = nil

#column_definitions(table_name) ⇒ Object

TODO: col_description is not supported ???



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/active_record/connection_adapters/pglite_adapter.rb', line 57

def column_definitions(table_name)
  query_rows(<<~SQL, "SCHEMA")
    SELECT a.attname, format_type(a.atttypid, a.atttypmod),
            pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
            c.collname, '' AS comment,
            #{supports_identity_columns? ? "attidentity" : quote("")} AS identity,
            #{supports_virtual_columns? ? "attgenerated" : quote("")} as attgenerated
      FROM pg_attribute a
      LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
      LEFT JOIN pg_type t ON a.atttypid = t.oid
      LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
      WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass
        AND a.attnum > 0 AND NOT a.attisdropped
      ORDER BY a.attnum
  SQL
end