Query
Object Hierarchy:
Description:
public class Query<T>
A generic SQL query builder for GObject-based types.
This class provides type-safe CRUD operations for GObject instances, automatically mapping object properties to database columns. It
supports INSERT, UPDATE, SELECT, and DELETE operations with automatic type conversion between GObject property types and SQLite column
types.
Supported GObject property types: - boolean (maps to INTEGER 0/1) - int (maps to INTEGER) - int64 (maps to INT64) - string (maps to TEXT)
- enum (maps to INTEGER)
**Important:** SQ.Query only works with GObject properties. When deserializing from the database (SELECT operations), all properties
found in the result set will be set on the object. If a property is read-only (`get;` only), GObject will throw an error when attempting
to set it. Therefore, properties that appear in SELECT queries must be settable (`get; set;`).
Parameters:
| T |
The GObject type to work with
|
Content:
Creation methods:
Methods:
- public bool compareProperty (T older, T newer, string prop, Type gtype)
Compares a property value between two objects.
- public void deleteId (int64 id)
Deletes a row from the table by ID.
- public ArrayList<int> fetchAllInt64 (Statement stmt)
Fetches all integer values from the first column of a query result.
- public ArrayList<string> fetchAllString (Statement stmt)
Fetches all string values from the first column of a query result.
- public string[] getColsExcept (string[]? except, string prefix = "")
Gets a list of column names, optionally excluding some and adding a
prefix.
- public int getInt (T obj, string prop, Type gtype)
Extracts an integer value from an object property.
- public string getText (T obj, string prop, Type gtype)
Extracts a text value from an object property.
- public int64 insert (T newer)
Inserts a new object into the database table.
- public void select (string where, ArrayList<T> ret)
Selects objects from the table matching a WHERE clause.
- public void selectExecute (Statement stmt, ArrayList<T> ret)
Executes a prepared SELECT statement and populates a result list.
- public bool selectExecuteInto (Statement stmt, T row)
Executes a prepared SELECT statement and populates a single object.
- public Statement selectPrepare (string q)
Prepares a SQL SELECT statement for execution.
- public void selectQuery (string q, ArrayList<T> ret)
Executes a raw SQL SELECT query and populates a result list.
- public async void select_async (string where, ArrayList<T> ret) throws ThreadError
Selects objects from the table matching a WHERE clause asynchronously.
- public void updateById (T newer)
Updates an existing object in the database by ID.
- public bool updateOld (T old, T newer)
Updates an existing object in the database, only changing modified
fields.
Fields: