TapKit::SQLExpression

Class/Module:
Class
In:
lib/tapkit/access/sql.rb
Parent:
Object

Methods

add_bind_variable
add_insert_list
add_join
add_order
add_select_list
add_select_list_with_function
add_update_list
append_item
assemble_aggregate
assemble_delete
assemble_insert
assemble_join
assemble_select
assemble_update
bind_variable
format_sql_string
format_value
join_clause
join_expression
must_use_bind_variable?
new
prepare_aggregate
prepare_delete
prepare_insert
prepare_select
prepare_update
should_use_bind_variable?
sql_escape_char
sql_for_attribute
sql_for_attribute_named
sql_for_attribute_path
sql_for_average_function
sql_for_case_insensitive_like
sql_for_conjoined_qualifiers
sql_for_count_all_function
sql_for_count_function
sql_for_date
sql_for_disjoined_qualifiers
sql_for_function
sql_for_key_comparison_qualifier
sql_for_key_value_qualifier
sql_for_max_function
sql_for_min_function
sql_for_negated_qualifier
sql_for_number
sql_for_qualifier
sql_for_string
sql_for_symbol
sql_for_value
sql_pattern
table_list
to_s
use_aliases?
use_bind_variables?

Attributes

aliases [R]
bind_variables [R]
encoding [RW]
entity [R]
group_by_string [R]
join_entities [R]
join_on [R]
join_relationships [R]
join_semantic [R]
list_string [R]
lock_clause [R]
order_by_string [R]
statement [RW]
use_aliases [W]
use_bind_variables [W]
value_list [R]
where_clause [R]

Public Class Methods

new( entity, encoding = nil )

Public Instance Methods

add_bind_variable( binding )

bind variables

add_insert_list( attribute, value )
add_join( left, right, semantic )
add_order( sort_ordering )

order by string

add_select_list( attribute, as = nil, grouping = false )
add_select_list_with_function( attribute, function, as = nil )
add_update_list( attribute, value )
append_item( string, list = nil )

list string

assemble_aggregate( qualifier, having_qualifier, fetch_order, select, column_list, table_list, join_clause, where_clause, group_by, having_clause, order_by )

SELECT group_by column_list FROM table_list join_semantic JOIN join_clause WHERE where_clause GROUP BY group_by HAVING having_clause ORDER BY order_clause

assemble_delete( qualifier, table_list, where_clause )

DELETE FROM table_list WHERE where_clause

assemble_insert( row, table_list, column_list, value_list )
assemble_join( left, right, semantic )
assemble_select( attributes, lock, qualifier, fetch_order, select, column_list, table_list, join_clause, where_clause, order_by, lock_clause )

attributes, lock, qualifier, fetchorder are unsupported.

 SELECT column_list FROM table_list lock_clause
 join_semantic JOIN join_clause WHERE where_clause ORDER BY order_clause
assemble_update( row, qualifier, table_list, update_list, where_clause )

UPDATE table_list SET update_list WHERE where_clause

bind_variable( attribute, value )

abstract

format_sql_string( sql, format = nil )
format_value( value, attribute )

abstract method. this is default implementation.

join_clause()

join

join_expression()
must_use_bind_variable?( attribute )
prepare_aggregate( aggregate_spec )

aggregate

prepare_delete( qualifier )

Generates a DELETE statement by the following steps:

  1. Generates where_clause.
  2. Invokes table_list to get the table name for the FROM clause..
  3. Invokes assemble_delete.
prepare_insert( row )

Generates a INSERT statement by the following steps:

  1. Invokes add_insert_list_attribute for each entry in row to prepare the comma-separated list of attributes and the corresponding list of values.
  2. Invokes table_list to get the tables name for the FROM clause.
  3. Invokes assemble_insert.
prepare_select( attributes, lock, fetch_spec )

Generates a SELECT statement by the following steps:

  1. Invokes add_select_list() for each in the attributes.
  2. Uses qualifier of the fetch_spec to generate where_clause.
  3. Invokes add_order() for each AttributeOrdering object in the fetch_spec.
  4. Invokes join_expression() to generate join_clause.
  5. Invokes table_list() to generate FROM clause.
  6. If the lock is true, invokes lock_clause to get the SQL string for locking selected rows.
  7. Invokes assemble_select(). After this, you can get the complete SELECT statement by calling statement().
prepare_update( row, qualifier )

Generates a UPDATE statement by the following steps:

  1. Invokes add_update_list_attribute for each entry in row to prepare the comma-separated list of "attribute = value" assignments.
  2. Generates where_clause.
  3. Invokes table_list to get the table name for the FROM clause.
  4. Invokes assemble_update.
should_use_bind_variable?( attribute )
sql_escape_char()

SQL string

sql_for_attribute( attribute )

attribute or name

sql_for_attribute_named( name )
sql_for_attribute_path( paths )
sql_for_average_function( column_name )
sql_for_case_insensitive_like( value, key )
sql_for_conjoined_qualifiers( qualifiers )

(<qualifier> AND <qualifier> AND … <qualifier>)

sql_for_count_all_function( column_name )
sql_for_count_function( column_name )
sql_for_date( date )
sql_for_disjoined_qualifiers( qualifiers )

(<qualifier> OR <qualifier> OR … <qualifier>)

sql_for_function( function, column_name )
sql_for_key_comparison_qualifier( qualifier )

left - sql_for_attribute_named, format_sql_string

 <left> <operator> <right>
sql_for_key_value_qualifier( qualifier )

key - sql_for_attribute_named, format_sql_string value - sql_for_value, format_value(sql_pattern)

 <key> <operator> <value>
sql_for_max_function( column_name )
sql_for_min_function( column_name )
sql_for_negated_qualifier( qualifier )

NOT (<qualifier>)

sql_for_number( number )
sql_for_qualifier( qualifier )
sql_for_string( string )
sql_for_symbol( symbol, value )
sql_for_value( keypath, object )
sql_pattern( pattern, escape = nil )
  • -> %

? -> _ % -> \% _ -> _ * -> * \? -> ?

table_list( entity, join = true )
to_s()
use_aliases?()
use_bind_variables?()