fix: ✨ fix how Table processes table names
This commit is contained in:
parent
cd9e9deab3
commit
637bb865b6
1 changed files with 11 additions and 1 deletions
|
@ -3,10 +3,20 @@
|
|||
module Timeseries
|
||||
module Hoarder
|
||||
class Table
|
||||
attr_reader :table_name, :table_schema, :table_id
|
||||
|
||||
def initialize(db, table_name, table_schema = "public")
|
||||
raise ArgumentError, "DB needs to be a Timeseries::Hoarder::Database!" unless db.is_a? Database
|
||||
|
||||
if (not table_name.is_a? String) or (not table_schema.is_a? String)
|
||||
raise ArgumentError, "Table name and schema must be strings!"
|
||||
end
|
||||
|
||||
@table_name = table_name
|
||||
@table_schema = table_schema
|
||||
|
||||
@table_id = "\"#{@table_schema}\".\"#{@table_name}\""
|
||||
|
||||
@db = db
|
||||
@pg = @db.pg
|
||||
|
||||
|
@ -21,7 +31,7 @@ module Timeseries
|
|||
@pg.transaction do
|
||||
@pg.exec("SELECT pg_advisory_lock(0)")
|
||||
|
||||
r = @pg.exec_params("SELECT 1 FROM information_schema.tables WHERE table_name = $1 AND table_schema = $2", [@table_name, @schema_name])
|
||||
r = @pg.exec_params("SELECT 1 FROM information_schema.tables WHERE table_name = $1 AND table_schema = $2", [@table_name, @table_schema])
|
||||
|
||||
if r.num_tuples >= 1
|
||||
@created = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue