using Invercargill.DataStructures; namespace InvercargillSql.Orm { /** * Represents schema metadata for a database table. * * TableSchema contains information about the table's columns, * primary key, and other metadata discovered through database * introspection. * * This class is used by the ORM to discover schema metadata * at runtime rather than requiring explicit configuration. */ public class TableSchema : Object { /** * The name of the table in the database. */ public string table_name { get; set; } /** * The columns in this table. */ public Vector columns { get; set; } /** * The name of the primary key column, or null if no primary key. */ public string? primary_key_column { get; set; } /** * Creates a new TableSchema instance. */ public TableSchema() { columns = new Vector(); } /** * Gets the ColumnSchema for a specific column name. * * @param name The column name to find * @return The ColumnSchema, or null if not found */ public ColumnSchema? get_column(string name) { foreach (var col in columns) { if (col.name == name) { return col; } } return null; } /** * Checks if a column is the primary key. * * @param column_name The column name to check * @return true if the column is the primary key */ public bool is_primary_key(string column_name) { return primary_key_column == column_name; } /** * Gets all columns that are auto-incrementing. * * @return A vector of auto-increment column schemas */ public Vector get_auto_increment_columns() { var result = new Vector(); foreach (var col in columns) { if (col.auto_increment) { result.add(col); } } return result; } } /** * Represents schema metadata for a single database column. * * ColumnSchema contains information about a column's type, * constraints, and other properties discovered through * database introspection. */ public class ColumnSchema : Object { /** * The name of the column in the database. */ public string name { get; set; } /** * The column type. */ public ColumnType column_type { get; set; } /** * Whether this column is the primary key. */ public bool is_primary_key { get; set; default = false; } /** * Whether this column auto-increments. */ public bool auto_increment { get; set; default = false; } /** * Whether this column is required (NOT NULL). */ public bool is_required { get; set; default = false; } /** * Creates a new ColumnSchema instance. */ public ColumnSchema() { column_type = ColumnType.TEXT; } } }