Substrate.Sql Module


This module defines the following types:

SqlConnector Type

Keeps a connection with a SQL database given by a connection string parameter upon construction. The SqlConnector can be used to execute queries or other commands over the SQL database.

Methods

Modifiers Return type Method name Method parameters Description
unit Close Closes the connection to the SQL database
SqlDataReader seq ExecQuery string, Object seq Executes the given query and returs a (lazy) sequence of results
int ExecUpdate string, Object seq Executes the given command and discards the results (useful for non-query commands such as updates)
ITerm ReadVar DbDataReader, IVar, int Returns an ITerm by parsing the DbDataReader depending on the type of the given variable

 

ASqlSubstrateUpdateTerm Type

An abstract SqlSubstrateUpdateTerm that is extended by modify terms, insert terms and delete terms

Implemented Interfaces

  • ITerm
  • ISubstrateUpdateTerm
  • ISubstrateTerm

Methods

Modifiers Return type Method name Method parameters Description
ITerm Apply ISubstitution
ITerm Normalize
ISubstitution option UnifyFrom ISubstitution, ITerm
static IDictionary<string, ITerm> dictApply ISubstitution, IDictionary<string, ITerm>

Properties

Return type Property name Description
IVar list Vars

 

SqlSubstrateModifyTerm Type

Base type: ASqlSubstrateUpdateTerm
A term that represents a modification over several rows in different tables of the database.

Implemented Interfaces

  • ITerm
  • ISubstrateUpdateTerm
  • ISubstrateTerm

Methods

Modifiers Return type Method name Method parameters Description
ITerm Apply ISubstitution
ITerm Normalize
ISubstitution option UnifyFrom ISubstitution, ITerm
string ToString
bool Equals Object
int GetHashCode

Properties

Return type Property name Description
ITerm Query Indicates over which rows the update needs to be applied
IDictionary<string, ITerm> ColsMapping Indicates what columns need to be modified and what new values they need to get
IVar list Vars

 

SqlSubstrateDeleteTerm Type

Base type: ASqlSubstrateUpdateTerm
A term that represents a deletion of several rows in a table on the database

Implemented Interfaces

  • ITerm
  • ISubstrateUpdateTerm
  • ISubstrateTerm

Methods

Modifiers Return type Method name Method parameters Description
ITerm Apply ISubstitution
ITerm Normalize
ISubstitution option UnifyFrom ISubstitution, ITerm
string ToString
bool Equals Object
int GetHashCode

Properties

Return type Property name Description
ITerm Query Indicates which rows are to be deleted
string Table Indicates on which table the deletion is to be performed
IVar list Vars

 

SqlSubstrateInsertTerm Type

Base type: ASqlSubstrateUpdateTerm
A term that represents an insertion of a single row in a table on the database

Implemented Interfaces

  • ITerm
  • ISubstrateUpdateTerm
  • ISubstrateTerm

Methods

Modifiers Return type Method name Method parameters Description
ITerm Apply ISubstitution
ITerm Normalize
ISubstitution option UnifyFrom ISubstitution, ITerm
string ToString
bool Equals Object
int GetHashCode

Properties

Return type Property name Description
string Table Indicates on which table the rows is going to be added
IDictionary<string, ITerm> Values Gives values to each of the columns in the new row
IVar list Vars

 

SqlSubstrate Type

A SqlSubstrate is an abstraction of a SQL database that can be used to issue queries, and perform updates (such as rows insertions/deletions).

Implemented Interfaces

  • ISubstrate

Methods

Modifiers Return type Method name Method parameters Description
bool HasTable string
Type GetColumnType string, string
bool modify SqlSubstrateModifyTerm
bool delete SqlSubstrateDeleteTerm
bool insert SqlSubstrateInsertTerm

Properties

Return type Property name Description
string ConnectionString
string SchemaFile

 

SqlCompiler Type

The SqlCompiler has functionality to transform SQL query terms into real SQL queries that can be executed on a SqlConnector.

Methods

Modifiers Return type Method name Method parameters Description
static Dictionary<a, b> dict
static List<a> vec
static unit addSqlOp string, string
static unit addPrefixSqlOp string, string
static unit init
static Expr sqlEq Expr, Expr
static Expr sqlNeq Expr, Expr
static Expr sqlAnd Expr, Expr
static unit err ITerm, string
static Expr * Variable * Expr list simplify Expr
static Expr * Variable * Expr list compile a, b, ITerm seq
static ISubstitution seq execQuery SqlConnector, a, Expr * Variable * Expr list, ISubstitution, IVar list
static bool execUpdate SqlConnector, a, Expr * Variable * Expr list, string * Expr list
static bool execDelete SqlConnector, a, Expr * Variable * Expr list, string
static bool execInsert SqlConnector, a, string, IDictionary<string, Expr>

Properties

Return type Property name Description
Logger log
Dictionary<string, SqlOp> sqlOps
Expr sqlTrue
Expr sqlFalse
Expr seq -> Expr sqlMultiAnd

 

SqlOp Type

Type to represent a SQL operator

Implemented Interfaces

  • IEquatable<SqlOp>
  • IStructuralEquatable
  • IComparable<SqlOp>
  • IComparable
  • IStructuralComparable

Methods

Modifiers Return type Method name Method parameters Description
int CompareTo SqlOp
int CompareTo Object
int CompareTo Object, IComparer
int GetHashCode IEqualityComparer
int GetHashCode
bool Equals Object, IEqualityComparer
bool Equals SqlOp
bool Equals Object

Properties

Return type Property name Description
string name
bool infix

 

TableId Type

Type to represent a SQL table. The scope is used to distinguish between tables that are in a nested query and its results therefore need to be treated independently

Implemented Interfaces

  • IEquatable<TableId>
  • IStructuralEquatable
  • IComparable<TableId>
  • IComparable
  • IStructuralComparable

Methods

Modifiers Return type Method name Method parameters Description
int CompareTo TableId
int CompareTo Object
int CompareTo Object, IComparer
int GetHashCode IEqualityComparer
int GetHashCode
bool Equals Object, IEqualityComparer
bool Equals TableId
bool Equals Object

Properties

Return type Property name Description
int scope
string name

 

Expr Type

Type to represent SQL expressions.

Implemented Interfaces

  • IEquatable<Expr>
  • IStructuralEquatable

Methods

Modifiers Return type Method name Method parameters Description
static Expr NewOp SqlOp, Expr list
static Expr NewConst IConst
static Expr NewVar Variable
static Expr NewColumn TableId, string
int GetHashCode IEqualityComparer
int GetHashCode
bool Equals Object, IEqualityComparer
Expr Map Expr -> Expr option
bool IsGround
string ToString
Expr Subst Dictionary<string, Expr>
bool Equals Expr
bool Equals Object

Properties

Return type Property name Description
int Tag
bool IsOp
bool IsConst
bool IsVar
bool IsColumn

 

Column Type

Base type: Expr
Table access

Implemented Interfaces

  • IEquatable<Expr>
  • IStructuralEquatable

Properties

Return type Property name Description
TableId Item1
string Item2

 

Var Type

Base type: Expr
Variable

Implemented Interfaces

  • IEquatable<Expr>
  • IStructuralEquatable

Properties

Return type Property name Description
Variable Item

 

Const Type

Base type: Expr
Constant

Implemented Interfaces

  • IEquatable<Expr>
  • IStructuralEquatable

Properties

Return type Property name Description
IConst Item

 

Op Type

Base type: Expr
Operation

Implemented Interfaces

  • IEquatable<Expr>
  • IStructuralEquatable

Properties

Return type Property name Description
SqlOp Item1
Expr list Item2

 

SqlWriter Type

A SqlWriter prints SQL Expr elements into SQL syntax using a StringBuilder

Methods

Modifiers Return type Method name Method parameters Description
unit pr Object
string get string
unit parm Object

Properties

Return type Property name Description
IDictionary<TableId, string> tables
List<Object> parms
string fromClause
Expr -> unit print

 

ActivePatterns Type

Defines the public interface on how to pattern match AST elements defined for the SqlSubstrate

Methods

Modifiers Return type Method name Method parameters Description
static ITerm list option |AndBool|_| ITerm Matches a conjunction
static ITerm list option |OrBool|_| ITerm Matches a disjunction
static ISubstrateQueryTerm option |AsBoolean|_| ITerm Matches an asBoolean construct (used to nest queries)
static string * string option |Column|_| ITerm Matches a table.column term

 

Builders Type

Defines the public interface on how to construct AST elements defined in the SqlSubstrate

Methods

Modifiers Return type Method name Method parameters Description
static ITerm AndBool ITerm list Constructs a conjunction
static ITerm OrBool ITerm list Constructs a disjunction
static ITerm AsBoolean ISubstrateQueryTerm Constructs an AsBoolean expression (used for nested substrate queries)

 

SqlPrimitives Type

Defines the primitive functions used to construct Application elements in the SqlSubstrate builders

Methods

Modifiers Return type Method name Method parameters Description
static Function option SolveOverloadOperator string, IType Given an overloaded function name and the type of one of its parameters it looks the type information to see if there is a match.

 

Automatically generated on 6/10/2011 2:28:40 PM
 

Last edited Jun 10, 2011 at 9:37 PM by gdecaso, version 5

Comments

No comments yet.