Class: RDF::DataObjects::Adapters::Postgres
- Extended by:
- Defaults
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do/adapters/postgres.rb
Overview
Postgres Adapter for RDF::DataObjects.
Class Method Summary collapse
-
.delete_sql ⇒ String
SQL prepared statement for deletions.
-
.insert_sql ⇒ String
SQL prepared statement for insertions.
-
.migrate?(do_repository, opts = {})
Indempotently migrate this database.
-
.multiple_insert_sql(count) ⇒ String
SQL prepared statement for multiple insertion.
Methods included from Defaults
count_sql, delete_sql, each_graph_sql, each_object_sql, each_predicate_sql, each_sql, each_subject_sql, insert_sql, query
Class Method Details
.delete_sql ⇒ String
SQL prepared statement for deletions
46 47 48 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do/adapters/postgres.rb', line 46 def self.delete_sql "DELETE FROM quads where (subject = ? AND predicate = ? AND object = ? AND context = ?)" end |
.insert_sql ⇒ String
SQL prepared statement for insertions
30 31 32 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do/adapters/postgres.rb', line 30 def self.insert_sql 'insert into quads (subject, predicate, object, context) VALUES (?, ?, ?, ?)' end |
.migrate?(do_repository, opts = {})
This method returns an undefined value.
Indempotently migrate this database.
18 19 20 21 22 23 24 25 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do/adapters/postgres.rb', line 18 def self.migrate?(do_repository, opts = {}) begin do_repository.exec('CREATE TABLE quads (subject varchar(255), predicate varchar(255), object varchar(255), context varchar(255), UNIQUE (subject, predicate, object, context))') rescue nil end begin do_repository.exec('CREATE INDEX quads_context_index ON quads (context)') rescue nil end begin do_repository.exec('CREATE INDEX quads_object_index ON quads (object)') rescue nil end begin do_repository.exec('CREATE INDEX quads_predicate_index ON quads (predicate)') rescue nil end begin do_repository.exec('CREATE INDEX quads_subject_index ON quads (subject)') rescue nil end do_repository.exec('CREATE OR REPLACE RULE "insert_ignore" AS ON INSERT TO quads WHERE EXISTS(SELECT true FROM quads WHERE subject = NEW.subject AND predicate = NEW.predicate AND object = NEW.object AND context = NEW.context) DO INSTEAD NOTHING;') end |
.multiple_insert_sql(count) ⇒ String
SQL prepared statement for multiple insertion
38 39 40 41 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-do-a92b866a7db7/lib/rdf/do/adapters/postgres.rb', line 38 def self.multiple_insert_sql(count) sql = 'insert into quads (subject, predicate, object, context) VALUES ' sql + (1..count).map { "(?, ?, ?, ?)" }.join(',') end |