Module: Pod4::SQLHelper

Included in:
PgInterface, TdsInterface
Defined in:
lib/pod4/sql_helper.rb

Overview

A mixin to help interfaces that need to generate SQL

Most of these methods return two things: an sql string with %s where each value should be; and an array of values to insert.

You can override placeholder() to change %s to something else. You can override quote() to change how values are quoted and quote_fld() to change how column names are quoted. Of course the SQL here won’t be suitable for all data source libraries even then, but, it gives us some common ground to start with.

You can call sql_subst() to turn the SQL and the values array into actual SQL – but don’t do that; you should call the parameterised query routines for the data source library instead.

Instance Method Summary collapse

Instance Method Details

#quoted_tableObject

Return the name of the table quoted as for inclusion in SQL. Might include the name of the schema, too, if you have set one.

table() is mandatory for an Interface, and if we have a schema it will be schema().



27
28
29
# File 'lib/pod4/sql_helper.rb', line 27

def quoted_table
  defined?(schema) && schema ? %Q|"#{schema}"."#{table}"| : %Q|"#{table}"|
end