From 341d8f3c54b48f073977fa87c3426788cfa5fb50 Mon Sep 17 00:00:00 2001 From: ez-plugins Date: Wed, 22 Apr 2026 22:45:27 +0200 Subject: [PATCH 1/5] fix(docs): resolve MD012/MD032/MD047 markdown lint violations - README.md: remove double blank lines before ## Features, ## Global and Per-Query Configuration, and ## License (MD012) - README.md: add missing trailing newline at end of file (MD047) - AGENTS.md: add blank lines before unordered lists (MD032) --- AGENTS.md | 2 ++ README.md | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e38704a..fbf6f77 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,6 +51,7 @@ Package `com.github.ezframework.javaquerybuilder.query`: | `sql.AbstractSqlDialect` | Base SQL rendering logic | **Key conventions**: + - Builder methods **always return `this`** (or the builder type) for fluent chaining. - All SQL values must go through the parameterized SQL path — never concatenate user input into SQL strings. - `Operator` is the single source of truth for supported operators; add new operators there first. @@ -106,6 +107,7 @@ Copilot agents can persist project-scoped notes in `/memories/repo/` to carry co The agent will store this under `/memories/repo/` and load it automatically in future sessions. **Useful things to store**: + - Verified build commands and their quirks - Project-specific conventions not obvious from the code - Known gotchas (e.g., "always run `mvn checkstyle:check` before committing") diff --git a/README.md b/README.md index ffc5f88..ce20ae0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ A lightweight, fluent Java library for building parameterized SQL queries and filtering in-memory data, no runtime dependencies required. - ## Features - Fluent, readable builder API for SELECT, INSERT, UPDATE, DELETE, and CREATE TABLE @@ -393,7 +392,6 @@ new SelectBuilder() .build(); // → SqlResult ``` - ## Global and Per-Query Configuration You can preset the default SQL dialect, default columns, limit, offset, and LIKE wrapping for all queries using `QueryBuilderDefaults`. This is useful for enforcing a project-wide dialect (e.g., always use SQLite) or customizing builder defaults. @@ -499,7 +497,6 @@ SqlDialect.SQLITE.renderDelete(query); `LIKE` values are automatically wrapped with `%` on both sides so `whereLike("name", "alice")` becomes `name LIKE ?` with parameter `%alice%`. - ## License -MIT \ No newline at end of file +MIT From cffe8dfd21bd2f7b838f17397d395ed6e8cfa6a2 Mon Sep 17 00:00:00 2001 From: ez-plugins Date: Wed, 22 Apr 2026 22:45:35 +0200 Subject: [PATCH 2/5] feat(builder): add ColumnType for type-safe column definitions in CreateBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add ColumnType final class with 25 fixed-type constants (TINYINT through UUID), 7 parameterised factory methods (varChar, charType, decimal, numeric, binary, varBinary, timestamp), and 4 chainable modifier methods (notNull, unique, autoIncrement, defaultValue) - Add CreateBuilder.column(String, ColumnType) overload; delegates to the existing column(String, String) via ColumnType.toSql() — fully backward compatible - Add ColumnTypeTest: 32 tests covering constants, factories, modifiers, chaining, and CreateBuilder integration --- .../query/builder/ColumnType.java | 297 ++++++++++++++++++ .../query/builder/CreateBuilder.java | 31 +- .../query/builder/ColumnTypeTest.java | 215 +++++++++++++ 3 files changed, 538 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnType.java create mode 100644 src/test/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnTypeTest.java diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnType.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnType.java new file mode 100644 index 0000000..37337a1 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnType.java @@ -0,0 +1,297 @@ +package com.github.ezframework.javaquerybuilder.query.builder; + +/** + * Type-safe column type definitions for use with + * {@link CreateBuilder#column(String, ColumnType)}. + * + *

Use the pre-defined constants for fixed-width types, the static factory + * methods for parameterised types, and the modifier methods to append + * column-level constraints:

+ * + *
{@code
+ * QueryBuilder.createTable("users")
+ *     .column("id",         ColumnType.INT.notNull().autoIncrement())
+ *     .column("username",   ColumnType.varChar(64).notNull().unique())
+ *     .column("balance",    ColumnType.decimal(10, 2))
+ *     .column("created_at", ColumnType.TIMESTAMP)
+ *     .primaryKey("id")
+ *     .build();
+ * // → CREATE TABLE users (
+ * //       id         INT NOT NULL AUTO_INCREMENT,
+ * //       username   VARCHAR(64) NOT NULL UNIQUE,
+ * //       balance    DECIMAL(10, 2),
+ * //       created_at TIMESTAMP,
+ * //       PRIMARY KEY (id))
+ * }
+ * + *

Raw SQL type strings are still accepted by + * {@link CreateBuilder#column(String, String)} for any type not covered here.

+ * + * @author EzFramework + * @version 1.1.0 + */ +public final class ColumnType { + + // ── Exact-width integer types ────────────────────────────────────────── + + /** 1-byte signed integer ({@code TINYINT}). Supported by MySQL, MariaDB. */ + public static final ColumnType TINYINT = new ColumnType("TINYINT"); + + /** 2-byte signed integer ({@code SMALLINT}). */ + public static final ColumnType SMALLINT = new ColumnType("SMALLINT"); + + /** 4-byte signed integer ({@code INT}). */ + public static final ColumnType INT = new ColumnType("INT"); + + /** 4-byte signed integer ({@code INTEGER}). Alias for {@link #INT} in most databases. */ + public static final ColumnType INTEGER = new ColumnType("INTEGER"); + + /** 8-byte signed integer ({@code BIGINT}). */ + public static final ColumnType BIGINT = new ColumnType("BIGINT"); + + // ── Floating-point types ─────────────────────────────────────────────── + + /** Single-precision floating point ({@code FLOAT}). */ + public static final ColumnType FLOAT = new ColumnType("FLOAT"); + + /** Double-precision floating point ({@code DOUBLE}). */ + public static final ColumnType DOUBLE = new ColumnType("DOUBLE"); + + /** Double-precision floating point ({@code REAL}). Standard SQL alias for {@link #DOUBLE}. */ + public static final ColumnType REAL = new ColumnType("REAL"); + + // ── Boolean ─────────────────────────────────────────────────────────── + + /** Boolean value ({@code BOOLEAN}). */ + public static final ColumnType BOOLEAN = new ColumnType("BOOLEAN"); + + // ── Fixed-size text types ────────────────────────────────────────────── + + /** + * Unbounded text ({@code TEXT}). + * For length-limited strings use {@link #varChar(int)}. + */ + public static final ColumnType TEXT = new ColumnType("TEXT"); + + /** Small text up to 255 characters ({@code TINYTEXT}). MySQL / MariaDB only. */ + public static final ColumnType TINYTEXT = new ColumnType("TINYTEXT"); + + /** Medium text up to 16 MB ({@code MEDIUMTEXT}). MySQL / MariaDB only. */ + public static final ColumnType MEDIUMTEXT = new ColumnType("MEDIUMTEXT"); + + /** Large text up to 4 GB ({@code LONGTEXT}). MySQL / MariaDB only. */ + public static final ColumnType LONGTEXT = new ColumnType("LONGTEXT"); + + /** Character large object ({@code CLOB}). Standard SQL; map to TEXT on MySQL. */ + public static final ColumnType CLOB = new ColumnType("CLOB"); + + // ── Binary types ─────────────────────────────────────────────────────── + + /** Binary large object ({@code BLOB}). */ + public static final ColumnType BLOB = new ColumnType("BLOB"); + + /** Small binary up to 255 bytes ({@code TINYBLOB}). MySQL / MariaDB only. */ + public static final ColumnType TINYBLOB = new ColumnType("TINYBLOB"); + + /** Medium binary up to 16 MB ({@code MEDIUMBLOB}). MySQL / MariaDB only. */ + public static final ColumnType MEDIUMBLOB = new ColumnType("MEDIUMBLOB"); + + /** Large binary up to 4 GB ({@code LONGBLOB}). MySQL / MariaDB only. */ + public static final ColumnType LONGBLOB = new ColumnType("LONGBLOB"); + + // ── Date and time types ──────────────────────────────────────────────── + + /** Calendar date without time-of-day ({@code DATE}). */ + public static final ColumnType DATE = new ColumnType("DATE"); + + /** Time-of-day without date ({@code TIME}). */ + public static final ColumnType TIME = new ColumnType("TIME"); + + /** Date and time without timezone ({@code DATETIME}). MySQL / MariaDB / SQLite. */ + public static final ColumnType DATETIME = new ColumnType("DATETIME"); + + /** Date and time, often auto-updated ({@code TIMESTAMP}). */ + public static final ColumnType TIMESTAMP = new ColumnType("TIMESTAMP"); + + // ── Miscellaneous types ──────────────────────────────────────────────── + + /** JSON document ({@code JSON}). MySQL 5.7+, PostgreSQL 9.2+, SQLite 3.38+. */ + public static final ColumnType JSON = new ColumnType("JSON"); + + /** + * Auto-incrementing 4-byte integer ({@code SERIAL}). + * PostgreSQL only; equivalent to {@code INT NOT NULL AUTO_INCREMENT} on MySQL. + */ + public static final ColumnType SERIAL = new ColumnType("SERIAL"); + + /** + * Auto-incrementing 8-byte integer ({@code BIGSERIAL}). + * PostgreSQL only; equivalent to {@code BIGINT NOT NULL AUTO_INCREMENT} on MySQL. + */ + public static final ColumnType BIGSERIAL = new ColumnType("BIGSERIAL"); + + /** + * Universally unique identifier ({@code UUID}). + * Native on PostgreSQL; stored as {@code CHAR(36)} or {@code BINARY(16)} on others. + */ + public static final ColumnType UUID = new ColumnType("UUID"); + + // ── Internal state ───────────────────────────────────────────────────── + + /** The SQL fragment representing this column type definition. */ + private final String sql; + + /** + * Creates a {@code ColumnType} from an arbitrary SQL type fragment. + * + *

Use this constructor for database-specific types not covered by the + * pre-defined constants, e.g. {@code new ColumnType("GEOMETRY")}.

+ * + * @param sql the SQL type string; must not be {@code null} or blank + */ + public ColumnType(final String sql) { + this.sql = sql; + } + + // ── Parameterised factory methods ────────────────────────────────────── + + /** + * Variable-length character string: {@code VARCHAR(length)}. + * + * @param length maximum number of characters; must be positive + * @return a new {@code ColumnType} representing {@code VARCHAR(length)} + */ + public static ColumnType varChar(final int length) { + return new ColumnType("VARCHAR(" + length + ")"); + } + + /** + * Fixed-length character string: {@code CHAR(length)}. + * + * @param length number of characters; must be positive + * @return a new {@code ColumnType} representing {@code CHAR(length)} + */ + public static ColumnType charType(final int length) { + return new ColumnType("CHAR(" + length + ")"); + } + + /** + * Exact decimal number: {@code DECIMAL(precision, scale)}. + * + * @param precision total number of significant digits; must be positive + * @param scale number of digits after the decimal point; must be ≥ 0 + * @return a new {@code ColumnType} representing {@code DECIMAL(precision, scale)} + */ + public static ColumnType decimal(final int precision, final int scale) { + return new ColumnType("DECIMAL(" + precision + ", " + scale + ")"); + } + + /** + * Exact numeric value: {@code NUMERIC(precision, scale)}. + * Equivalent to {@link #decimal(int, int)} in most databases. + * + * @param precision total number of significant digits; must be positive + * @param scale number of digits after the decimal point; must be ≥ 0 + * @return a new {@code ColumnType} representing {@code NUMERIC(precision, scale)} + */ + public static ColumnType numeric(final int precision, final int scale) { + return new ColumnType("NUMERIC(" + precision + ", " + scale + ")"); + } + + /** + * Fixed-length binary string: {@code BINARY(length)}. + * + * @param length number of bytes; must be positive + * @return a new {@code ColumnType} representing {@code BINARY(length)} + */ + public static ColumnType binary(final int length) { + return new ColumnType("BINARY(" + length + ")"); + } + + /** + * Variable-length binary string: {@code VARBINARY(length)}. + * + * @param length maximum number of bytes; must be positive + * @return a new {@code ColumnType} representing {@code VARBINARY(length)} + */ + public static ColumnType varBinary(final int length) { + return new ColumnType("VARBINARY(" + length + ")"); + } + + /** + * Timestamp with fractional seconds precision: {@code TIMESTAMP(precision)}. + * Useful for {@code TIMESTAMP(6)} (microseconds) on MySQL and PostgreSQL. + * + * @param precision fractional seconds digits (0–6); must be between 0 and 6 inclusive + * @return a new {@code ColumnType} representing {@code TIMESTAMP(precision)} + */ + public static ColumnType timestamp(final int precision) { + return new ColumnType("TIMESTAMP(" + precision + ")"); + } + + // ── Column-level constraint modifiers ────────────────────────────────── + + /** + * Appends {@code NOT NULL} to this column type. + * + * @return a new {@code ColumnType} with {@code NOT NULL} appended + */ + public ColumnType notNull() { + return new ColumnType(sql + " NOT NULL"); + } + + /** + * Appends {@code UNIQUE} to this column type. + * + * @return a new {@code ColumnType} with {@code UNIQUE} appended + */ + public ColumnType unique() { + return new ColumnType(sql + " UNIQUE"); + } + + /** + * Appends {@code AUTO_INCREMENT} to this column type (MySQL / MariaDB). + * Use {@link #SERIAL} or {@link #BIGSERIAL} for PostgreSQL auto-increment columns. + * + * @return a new {@code ColumnType} with {@code AUTO_INCREMENT} appended + */ + public ColumnType autoIncrement() { + return new ColumnType(sql + " AUTO_INCREMENT"); + } + + /** + * Appends {@code DEFAULT value} to this column type. + * + *

The {@code value} string is inserted verbatim into the SQL column definition. + * Use only static, known-safe values here (e.g. {@code "0"}, {@code "false"}, + * {@code "CURRENT_TIMESTAMP"}). Never pass user-supplied input.

+ * + * @param value the default SQL expression or literal to append; must not be {@code null} + * @return a new {@code ColumnType} with {@code DEFAULT value} appended + */ + public ColumnType defaultValue(final String value) { + return new ColumnType(sql + " DEFAULT " + value); + } + + // ── Accessors ────────────────────────────────────────────────────────── + + /** + * Returns the SQL fragment for this column type, including any modifiers. + * + * @return the SQL column type string (e.g. {@code "VARCHAR(64) NOT NULL"}) + */ + public String toSql() { + return sql; + } + + /** + * Returns the SQL fragment for this column type. + * Equivalent to {@link #toSql()}. + * + * @return the SQL column type string + */ + @Override + public String toString() { + return sql; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/CreateBuilder.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/CreateBuilder.java index b3c1839..9c8ddcf 100644 --- a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/CreateBuilder.java +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/CreateBuilder.java @@ -39,16 +39,37 @@ public CreateBuilder table(String table) { } /** - * Adds a column definition. - * @param name the column name - * @param sqlType the SQL type (e.g. "VARCHAR(255)", "INT") - * @return this builder + * Adds a column definition using a raw SQL type string. + * + * @param name the column name + * @param sqlType the SQL type string (e.g. {@code "VARCHAR(255)"}, {@code "INT NOT NULL"}) + * @return this builder instance for chaining */ - public CreateBuilder column(String name, String sqlType) { + public CreateBuilder column(final String name, final String sqlType) { columns.put(name, sqlType); return this; } + /** + * Adds a column definition using a type-safe {@link ColumnType}. + * + *

Example:

+ *
{@code
+     * QueryBuilder.createTable("users")
+     *     .column("id",       ColumnType.INT.notNull().autoIncrement())
+     *     .column("username", ColumnType.varChar(64).notNull())
+     *     .primaryKey("id")
+     *     .build();
+     * }
+ * + * @param name the column name + * @param columnType the column type; must not be {@code null} + * @return this builder instance for chaining + */ + public CreateBuilder column(final String name, final ColumnType columnType) { + return column(name, columnType.toSql()); + } + /** * Adds a primary key column. * @param name the column name diff --git a/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnTypeTest.java b/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnTypeTest.java new file mode 100644 index 0000000..7fd6e65 --- /dev/null +++ b/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/ColumnTypeTest.java @@ -0,0 +1,215 @@ +package com.github.ezframework.javaquerybuilder.query.builder; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ColumnTypeTest { + + // ── Constants ──────────────────────────────────────────────────────── + + @Test + void intConstantHasCorrectSql() { + assertEquals("INT", ColumnType.INT.toSql()); + } + + @Test + void bigintConstantHasCorrectSql() { + assertEquals("BIGINT", ColumnType.BIGINT.toSql()); + } + + @Test + void smallintConstantHasCorrectSql() { + assertEquals("SMALLINT", ColumnType.SMALLINT.toSql()); + } + + @Test + void tinyintConstantHasCorrectSql() { + assertEquals("TINYINT", ColumnType.TINYINT.toSql()); + } + + @Test + void integerConstantHasCorrectSql() { + assertEquals("INTEGER", ColumnType.INTEGER.toSql()); + } + + @Test + void floatConstantHasCorrectSql() { + assertEquals("FLOAT", ColumnType.FLOAT.toSql()); + } + + @Test + void doubleConstantHasCorrectSql() { + assertEquals("DOUBLE", ColumnType.DOUBLE.toSql()); + } + + @Test + void realConstantHasCorrectSql() { + assertEquals("REAL", ColumnType.REAL.toSql()); + } + + @Test + void booleanConstantHasCorrectSql() { + assertEquals("BOOLEAN", ColumnType.BOOLEAN.toSql()); + } + + @Test + void textConstantHasCorrectSql() { + assertEquals("TEXT", ColumnType.TEXT.toSql()); + } + + @Test + void blobConstantHasCorrectSql() { + assertEquals("BLOB", ColumnType.BLOB.toSql()); + } + + @Test + void dateConstantHasCorrectSql() { + assertEquals("DATE", ColumnType.DATE.toSql()); + } + + @Test + void timeConstantHasCorrectSql() { + assertEquals("TIME", ColumnType.TIME.toSql()); + } + + @Test + void datetimeConstantHasCorrectSql() { + assertEquals("DATETIME", ColumnType.DATETIME.toSql()); + } + + @Test + void timestampConstantHasCorrectSql() { + assertEquals("TIMESTAMP", ColumnType.TIMESTAMP.toSql()); + } + + @Test + void jsonConstantHasCorrectSql() { + assertEquals("JSON", ColumnType.JSON.toSql()); + } + + @Test + void serialConstantHasCorrectSql() { + assertEquals("SERIAL", ColumnType.SERIAL.toSql()); + } + + @Test + void bigserialConstantHasCorrectSql() { + assertEquals("BIGSERIAL", ColumnType.BIGSERIAL.toSql()); + } + + @Test + void uuidConstantHasCorrectSql() { + assertEquals("UUID", ColumnType.UUID.toSql()); + } + + // ── Factory methods ────────────────────────────────────────────────── + + @Test + void varCharFactoryBuildsCorrectSql() { + assertEquals("VARCHAR(255)", ColumnType.varChar(255).toSql()); + } + + @Test + void charTypeFactoryBuildsCorrectSql() { + assertEquals("CHAR(10)", ColumnType.charType(10).toSql()); + } + + @Test + void decimalFactoryBuildsCorrectSql() { + assertEquals("DECIMAL(10, 2)", ColumnType.decimal(10, 2).toSql()); + } + + @Test + void numericFactoryBuildsCorrectSql() { + assertEquals("NUMERIC(8, 4)", ColumnType.numeric(8, 4).toSql()); + } + + @Test + void binaryFactoryBuildsCorrectSql() { + assertEquals("BINARY(16)", ColumnType.binary(16).toSql()); + } + + @Test + void varBinaryFactoryBuildsCorrectSql() { + assertEquals("VARBINARY(512)", ColumnType.varBinary(512).toSql()); + } + + @Test + void timestampWithPrecisionFactoryBuildsCorrectSql() { + assertEquals("TIMESTAMP(6)", ColumnType.timestamp(6).toSql()); + } + + // ── Modifier methods ───────────────────────────────────────────────── + + @Test + void notNullAppendsSuffix() { + assertEquals("INT NOT NULL", ColumnType.INT.notNull().toSql()); + } + + @Test + void uniqueAppendsSuffix() { + assertEquals("VARCHAR(64) UNIQUE", ColumnType.varChar(64).unique().toSql()); + } + + @Test + void autoIncrementAppendsSuffix() { + assertEquals("INT AUTO_INCREMENT", ColumnType.INT.autoIncrement().toSql()); + } + + @Test + void defaultValueAppendsSuffix() { + assertEquals("BOOLEAN DEFAULT false", ColumnType.BOOLEAN.defaultValue("false").toSql()); + } + + @Test + void modifiersCombineInOrder() { + final String expected = "INT NOT NULL AUTO_INCREMENT"; + assertEquals(expected, ColumnType.INT.notNull().autoIncrement().toSql()); + } + + @Test + void varCharWithNotNullAndUnique() { + final String expected = "VARCHAR(64) NOT NULL UNIQUE"; + assertEquals(expected, ColumnType.varChar(64).notNull().unique().toSql()); + } + + // ── toString / public constructor ──────────────────────────────────── + + @Test + void toStringMatchesToSql() { + assertEquals(ColumnType.TEXT.toSql(), ColumnType.TEXT.toString()); + } + + @Test + void toStringOnFactoryMatchesToSql() { + final ColumnType ct = ColumnType.varChar(128); + assertEquals(ct.toSql(), ct.toString()); + } + + @Test + void publicConstructorAcceptsCustomType() { + assertEquals("GEOMETRY", new ColumnType("GEOMETRY").toSql()); + } + + // ── CreateBuilder integration ──────────────────────────────────────── + + @Test + void createBuilderAcceptsColumnTypeOverload() { + final String sql = new CreateBuilder() + .table("users") + .column("id", ColumnType.INT.notNull().autoIncrement()) + .column("username", ColumnType.varChar(64).notNull()) + .column("score", ColumnType.decimal(5, 2)) + .primaryKey("id") + .build() + .getSql(); + assertEquals( + "CREATE TABLE users (" + + "id INT NOT NULL AUTO_INCREMENT, " + + "username VARCHAR(64) NOT NULL, " + + "score DECIMAL(5, 2), " + + "PRIMARY KEY (id))", + sql); + } +} From d771287e6d796ee4d049b424957d9808fdbc05b3 Mon Sep 17 00:00:00 2001 From: ez-plugins Date: Wed, 22 Apr 2026 22:45:41 +0200 Subject: [PATCH 3/5] docs(queries): update create.md with ColumnType usage guide and type reference - Replace minimal example with full ColumnType-based table definition - Add ColumnType section: fixed-type constant table, parameterised factory method table, modifier chain table, and custom-type examples - Expand IF NOT EXISTS and composite-PK examples to use ColumnType - Update method reference table to include column(String, ColumnType) --- docs/queries/create.md | 119 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 107 insertions(+), 12 deletions(-) diff --git a/docs/queries/create.md b/docs/queries/create.md index 22faf4c..1c9651b 100644 --- a/docs/queries/create.md +++ b/docs/queries/create.md @@ -20,20 +20,108 @@ description: "Building CREATE TABLE statements with CreateBuilder" ## Overview `CreateBuilder` builds `CREATE TABLE` statements with optional `IF NOT EXISTS` -guards and composite primary keys: +guards and composite primary keys. Column types can be specified as raw SQL +strings or as type-safe `ColumnType` constants and factory methods. ```java +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; import com.github.ezframework.javaquerybuilder.query.builder.QueryBuilder; import com.github.ezframework.javaquerybuilder.query.sql.SqlResult; SqlResult result = QueryBuilder.createTable("users") - .column("id", "INT") - .column("name", "VARCHAR(64)") - .column("email", "VARCHAR(255)") + .column("id", ColumnType.INT.notNull().autoIncrement()) + .column("username", ColumnType.varChar(64).notNull().unique()) + .column("balance", ColumnType.decimal(10, 2)) + .column("created_at", ColumnType.TIMESTAMP) .primaryKey("id") .build(); -// → CREATE TABLE users (id INT, name VARCHAR(64), email VARCHAR(255), PRIMARY KEY (id)) +// → CREATE TABLE users ( +// id INT NOT NULL AUTO_INCREMENT, +// username VARCHAR(64) NOT NULL UNIQUE, +// balance DECIMAL(10, 2), +// created_at TIMESTAMP, +// PRIMARY KEY (id)) +``` + +--- + +## ColumnType — type-safe column definitions + +`ColumnType` provides pre-defined constants for all common SQL types, factory +methods for parameterised types, and chainable modifier methods for column-level +constraints. + +### Fixed-width types + +| Constant | SQL | Notes | +|----------|-----|-------| +| `ColumnType.TINYINT` | `TINYINT` | 1-byte integer; MySQL / MariaDB | +| `ColumnType.SMALLINT` | `SMALLINT` | 2-byte integer | +| `ColumnType.INT` | `INT` | 4-byte integer | +| `ColumnType.INTEGER` | `INTEGER` | Alias for `INT` in most databases | +| `ColumnType.BIGINT` | `BIGINT` | 8-byte integer | +| `ColumnType.FLOAT` | `FLOAT` | Single-precision float | +| `ColumnType.DOUBLE` | `DOUBLE` | Double-precision float | +| `ColumnType.REAL` | `REAL` | Standard SQL alias for `DOUBLE` | +| `ColumnType.BOOLEAN` | `BOOLEAN` | Boolean value | +| `ColumnType.TEXT` | `TEXT` | Unbounded text | +| `ColumnType.TINYTEXT` | `TINYTEXT` | Up to 255 chars; MySQL / MariaDB | +| `ColumnType.MEDIUMTEXT` | `MEDIUMTEXT` | Up to 16 MB; MySQL / MariaDB | +| `ColumnType.LONGTEXT` | `LONGTEXT` | Up to 4 GB; MySQL / MariaDB | +| `ColumnType.CLOB` | `CLOB` | Character large object (standard SQL) | +| `ColumnType.BLOB` | `BLOB` | Binary large object | +| `ColumnType.TINYBLOB` | `TINYBLOB` | Up to 255 bytes; MySQL / MariaDB | +| `ColumnType.MEDIUMBLOB` | `MEDIUMBLOB` | Up to 16 MB; MySQL / MariaDB | +| `ColumnType.LONGBLOB` | `LONGBLOB` | Up to 4 GB; MySQL / MariaDB | +| `ColumnType.DATE` | `DATE` | Calendar date | +| `ColumnType.TIME` | `TIME` | Time-of-day | +| `ColumnType.DATETIME` | `DATETIME` | Date + time; MySQL / MariaDB / SQLite | +| `ColumnType.TIMESTAMP` | `TIMESTAMP` | Date + time; often auto-updated | +| `ColumnType.JSON` | `JSON` | JSON document; MySQL 5.7+, PG 9.2+, SQLite 3.38+ | +| `ColumnType.SERIAL` | `SERIAL` | Auto-increment 4-byte int (PostgreSQL) | +| `ColumnType.BIGSERIAL` | `BIGSERIAL` | Auto-increment 8-byte int (PostgreSQL) | +| `ColumnType.UUID` | `UUID` | UUID; native on PostgreSQL | + +### Parameterised factory methods + +| Method | SQL output | Description | +|--------|-----------|-------------| +| `ColumnType.varChar(n)` | `VARCHAR(n)` | Variable-length string up to `n` chars | +| `ColumnType.charType(n)` | `CHAR(n)` | Fixed-length string of `n` chars | +| `ColumnType.decimal(p, s)` | `DECIMAL(p, s)` | Exact decimal with `p` total and `s` fraction digits | +| `ColumnType.numeric(p, s)` | `NUMERIC(p, s)` | Exact numeric; equivalent to `DECIMAL` in most databases | +| `ColumnType.binary(n)` | `BINARY(n)` | Fixed-length binary of `n` bytes | +| `ColumnType.varBinary(n)` | `VARBINARY(n)` | Variable-length binary up to `n` bytes | +| `ColumnType.timestamp(p)` | `TIMESTAMP(p)` | Timestamp with `p` fractional-seconds digits (0–6) | + +### Modifier methods (chainable) + +Modifiers return a new `ColumnType` instance and can be chained in any order: + +| Method | Appends | Example | +|--------|---------|---------| +| `.notNull()` | `NOT NULL` | `ColumnType.INT.notNull()` → `INT NOT NULL` | +| `.unique()` | `UNIQUE` | `ColumnType.varChar(64).unique()` → `VARCHAR(64) UNIQUE` | +| `.autoIncrement()` | `AUTO_INCREMENT` | `ColumnType.INT.notNull().autoIncrement()` → `INT NOT NULL AUTO_INCREMENT` | +| `.defaultValue(val)` | `DEFAULT val` | `ColumnType.BOOLEAN.defaultValue("false")` → `BOOLEAN DEFAULT false` | + +{: .warning } +> `.defaultValue(val)` inserts the string verbatim into the SQL. Use only +> static, known-safe values (e.g. `"0"`, `"false"`, `"CURRENT_TIMESTAMP"`). +> Never pass user-supplied input. + +### Custom types + +For database-specific types not covered by the built-in constants, pass a raw +SQL string directly to `column()` or use the public `ColumnType` constructor: + +```java +// Raw SQL string (backward compatible) +.column("geom", "GEOMETRY NOT NULL") + +// Public constructor for custom type +.column("geom", new ColumnType("GEOMETRY NOT NULL")) ``` --- @@ -43,13 +131,17 @@ SqlResult result = QueryBuilder.createTable("users") ```java SqlResult result = QueryBuilder.createTable("sessions") .ifNotExists() - .column("token", "VARCHAR(128)") - .column("user_id", "INT") - .column("expires_at", "TIMESTAMP") + .column("token", ColumnType.varChar(128).notNull()) + .column("user_id", ColumnType.INT) + .column("expires_at", ColumnType.TIMESTAMP) .primaryKey("token") .build(); -// → CREATE TABLE IF NOT EXISTS sessions (token VARCHAR(128), user_id INT, expires_at TIMESTAMP, PRIMARY KEY (token)) +// → CREATE TABLE IF NOT EXISTS sessions ( +// token VARCHAR(128) NOT NULL, +// user_id INT, +// expires_at TIMESTAMP, +// PRIMARY KEY (token)) ``` --- @@ -58,8 +150,8 @@ SqlResult result = QueryBuilder.createTable("sessions") ```java SqlResult result = QueryBuilder.createTable("user_roles") - .column("user_id", "INT") - .column("role_id", "INT") + .column("user_id", ColumnType.INT) + .column("role_id", ColumnType.INT) .primaryKey("user_id") .primaryKey("role_id") .build(); @@ -74,8 +166,11 @@ SqlResult result = QueryBuilder.createTable("user_roles") | Method | Returns | Description | |--------|---------|-------------| | `table(String name)` | `CreateBuilder` | Set table name | -| `column(String name, String sqlType)` | `CreateBuilder` | Add a column definition | +| `column(String name, String sqlType)` | `CreateBuilder` | Add a column with a raw SQL type string | +| `column(String name, ColumnType type)` | `CreateBuilder` | Add a column with a type-safe `ColumnType` | | `primaryKey(String name)` | `CreateBuilder` | Declare a primary key column | | `ifNotExists()` | `CreateBuilder` | Add `IF NOT EXISTS` guard | | `build()` | `SqlResult` | Render; throws `IllegalStateException` if table or columns are missing | | `build(SqlDialect dialect)` | `SqlResult` | Render with specified dialect | + +| `build(SqlDialect dialect)` | `SqlResult` | Render with specified dialect | From c8dade62154cfef736d1f2d9de00807081a911dd Mon Sep 17 00:00:00 2001 From: ez-plugins Date: Wed, 22 Apr 2026 22:35:49 +0200 Subject: [PATCH 4/5] feat(col): add per-type shorthand classes in builder.col package Each class in the new col package wraps a single ColumnType constant or factory method behind a concise name and a uniform of() / of(params) factory. Developers can use a wildcard import to write: import com.github.ezframework.javaquerybuilder.query.builder.col.*; .column("id", Int.of().notNull().autoIncrement()) .column("username", VarChar.of(64).notNull().unique()) .column("price", Decimal.of(10, 2)) .column("created_at", Timestamp.of()) instead of prefixing every type with ColumnType. Classes added (31 total): Fixed types: TinyInt, SmallInt, Int, BigInt, SqlFloat, SqlDouble, Real, Bool, Text, TinyText, MediumText, LongText, Clob, Blob, TinyBlob, MediumBlob, LongBlob, Date, Time, DateTime, Json, Serial, BigSerial, Uuid Parameterised types: Timestamp (overloaded of() / of(int)), VarChar, Char, Decimal, Numeric, Binary, VarBinary - SqlFloat / SqlDouble / Bool named to avoid shadowing java.lang types when the package is wildcard-imported - ColTypesTest: 34 tests covering all classes and modifier chaining --- .../query/builder/col/BigInt.java | 33 +++ .../query/builder/col/BigSerial.java | 33 +++ .../query/builder/col/Binary.java | 34 +++ .../query/builder/col/Blob.java | 33 +++ .../query/builder/col/Bool.java | 34 +++ .../query/builder/col/Char.java | 34 +++ .../query/builder/col/Clob.java | 33 +++ .../query/builder/col/Date.java | 33 +++ .../query/builder/col/DateTime.java | 34 +++ .../query/builder/col/Decimal.java | 35 +++ .../query/builder/col/Int.java | 33 +++ .../query/builder/col/Json.java | 33 +++ .../query/builder/col/LongBlob.java | 33 +++ .../query/builder/col/LongText.java | 33 +++ .../query/builder/col/MediumBlob.java | 33 +++ .../query/builder/col/MediumText.java | 33 +++ .../query/builder/col/Numeric.java | 36 ++++ .../query/builder/col/Real.java | 33 +++ .../query/builder/col/Serial.java | 33 +++ .../query/builder/col/SmallInt.java | 33 +++ .../query/builder/col/SqlDouble.java | 34 +++ .../query/builder/col/SqlFloat.java | 34 +++ .../query/builder/col/Text.java | 33 +++ .../query/builder/col/Time.java | 33 +++ .../query/builder/col/Timestamp.java | 47 +++++ .../query/builder/col/TinyBlob.java | 33 +++ .../query/builder/col/TinyInt.java | 33 +++ .../query/builder/col/TinyText.java | 33 +++ .../query/builder/col/Uuid.java | 33 +++ .../query/builder/col/VarBinary.java | 34 +++ .../query/builder/col/VarChar.java | 34 +++ .../query/builder/col/ColTypesTest.java | 199 ++++++++++++++++++ 32 files changed, 1249 insertions(+) create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigInt.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigSerial.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Binary.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Blob.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Bool.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Char.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Clob.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Date.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/DateTime.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Decimal.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Int.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Json.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongBlob.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongText.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumBlob.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumText.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Numeric.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Real.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Serial.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SmallInt.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlDouble.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlFloat.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Text.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Time.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Timestamp.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyBlob.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyInt.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyText.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Uuid.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarBinary.java create mode 100644 src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarChar.java create mode 100644 src/test/java/com/github/ezframework/javaquerybuilder/query/builder/col/ColTypesTest.java diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigInt.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigInt.java new file mode 100644 index 0000000..071ddcd --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigInt.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code BIGINT}. + * + *

Delegates to {@link ColumnType#BIGINT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("user_id", BigInt.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#BIGINT + */ +public final class BigInt { + + /** Prevent instantiation. */ + private BigInt() { + } + + /** + * Returns the {@code BIGINT} column type. + * + * @return a {@link ColumnType} representing {@code BIGINT} + */ + public static ColumnType of() { + return ColumnType.BIGINT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigSerial.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigSerial.java new file mode 100644 index 0000000..47ff101 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/BigSerial.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code BIGSERIAL} (auto-incrementing 8-byte integer; PostgreSQL). + * + *

Delegates to {@link ColumnType#BIGSERIAL}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("id", BigSerial.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#BIGSERIAL + */ +public final class BigSerial { + + /** Prevent instantiation. */ + private BigSerial() { + } + + /** + * Returns the {@code BIGSERIAL} column type. + * + * @return a {@link ColumnType} representing {@code BIGSERIAL} + */ + public static ColumnType of() { + return ColumnType.BIGSERIAL; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Binary.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Binary.java new file mode 100644 index 0000000..3bce295 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Binary.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code BINARY(length)} (fixed-length binary string). + * + *

Delegates to {@link ColumnType#binary(int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("hash", Binary.of(32).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#binary(int) + */ +public final class Binary { + + /** Prevent instantiation. */ + private Binary() { + } + + /** + * Returns the {@code BINARY(length)} column type. + * + * @param length number of bytes; must be positive + * @return a {@link ColumnType} representing {@code BINARY(length)} + */ + public static ColumnType of(final int length) { + return ColumnType.binary(length); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Blob.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Blob.java new file mode 100644 index 0000000..16cb899 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Blob.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code BLOB} (binary large object). + * + *

Delegates to {@link ColumnType#BLOB}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("data", Blob.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#BLOB + */ +public final class Blob { + + /** Prevent instantiation. */ + private Blob() { + } + + /** + * Returns the {@code BLOB} column type. + * + * @return a {@link ColumnType} representing {@code BLOB} + */ + public static ColumnType of() { + return ColumnType.BLOB; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Bool.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Bool.java new file mode 100644 index 0000000..189d247 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Bool.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code BOOLEAN}. + * + *

Named {@code Bool} to avoid shadowing {@link java.lang.Boolean}. + * Delegates to {@link ColumnType#BOOLEAN}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("active", Bool.of().notNull().defaultValue("true"))
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#BOOLEAN + */ +public final class Bool { + + /** Prevent instantiation. */ + private Bool() { + } + + /** + * Returns the {@code BOOLEAN} column type. + * + * @return a {@link ColumnType} representing {@code BOOLEAN} + */ + public static ColumnType of() { + return ColumnType.BOOLEAN; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Char.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Char.java new file mode 100644 index 0000000..68a8ea3 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Char.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code CHAR(length)} (fixed-length character string). + * + *

Delegates to {@link ColumnType#charType(int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("country_code", Char.of(2).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#charType(int) + */ +public final class Char { + + /** Prevent instantiation. */ + private Char() { + } + + /** + * Returns the {@code CHAR(length)} column type. + * + * @param length number of characters; must be positive + * @return a {@link ColumnType} representing {@code CHAR(length)} + */ + public static ColumnType of(final int length) { + return ColumnType.charType(length); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Clob.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Clob.java new file mode 100644 index 0000000..c44dfbd --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Clob.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code CLOB} (character large object; standard SQL). + * + *

Delegates to {@link ColumnType#CLOB}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("report", Clob.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#CLOB + */ +public final class Clob { + + /** Prevent instantiation. */ + private Clob() { + } + + /** + * Returns the {@code CLOB} column type. + * + * @return a {@link ColumnType} representing {@code CLOB} + */ + public static ColumnType of() { + return ColumnType.CLOB; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Date.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Date.java new file mode 100644 index 0000000..b39d9b3 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Date.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code DATE} (calendar date without time-of-day). + * + *

Delegates to {@link ColumnType#DATE}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("birth_date", Date.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#DATE + */ +public final class Date { + + /** Prevent instantiation. */ + private Date() { + } + + /** + * Returns the {@code DATE} column type. + * + * @return a {@link ColumnType} representing {@code DATE} + */ + public static ColumnType of() { + return ColumnType.DATE; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/DateTime.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/DateTime.java new file mode 100644 index 0000000..b5aa587 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/DateTime.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code DATETIME} (date and time without timezone; + * MySQL / MariaDB / SQLite). + * + *

Delegates to {@link ColumnType#DATETIME}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("scheduled_at", DateTime.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#DATETIME + */ +public final class DateTime { + + /** Prevent instantiation. */ + private DateTime() { + } + + /** + * Returns the {@code DATETIME} column type. + * + * @return a {@link ColumnType} representing {@code DATETIME} + */ + public static ColumnType of() { + return ColumnType.DATETIME; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Decimal.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Decimal.java new file mode 100644 index 0000000..07e298b --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Decimal.java @@ -0,0 +1,35 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code DECIMAL(precision, scale)}. + * + *

Delegates to {@link ColumnType#decimal(int, int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("price", Decimal.of(10, 2).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#decimal(int, int) + */ +public final class Decimal { + + /** Prevent instantiation. */ + private Decimal() { + } + + /** + * Returns the {@code DECIMAL(precision, scale)} column type. + * + * @param precision total number of significant digits; must be positive + * @param scale number of digits after the decimal point; must be ≥ 0 + * @return a {@link ColumnType} representing {@code DECIMAL(precision, scale)} + */ + public static ColumnType of(final int precision, final int scale) { + return ColumnType.decimal(precision, scale); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Int.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Int.java new file mode 100644 index 0000000..04c9e0d --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Int.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code INT}. + * + *

Delegates to {@link ColumnType#INT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("id", Int.of().notNull().autoIncrement())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#INT + */ +public final class Int { + + /** Prevent instantiation. */ + private Int() { + } + + /** + * Returns the {@code INT} column type. + * + * @return a {@link ColumnType} representing {@code INT} + */ + public static ColumnType of() { + return ColumnType.INT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Json.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Json.java new file mode 100644 index 0000000..c551f44 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Json.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code JSON} documents. + * + *

Delegates to {@link ColumnType#JSON}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("metadata", Json.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#JSON + */ +public final class Json { + + /** Prevent instantiation. */ + private Json() { + } + + /** + * Returns the {@code JSON} column type. + * + * @return a {@link ColumnType} representing {@code JSON} + */ + public static ColumnType of() { + return ColumnType.JSON; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongBlob.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongBlob.java new file mode 100644 index 0000000..930ce61 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongBlob.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code LONGBLOB} (up to 4 GB; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#LONGBLOB}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("file_data", LongBlob.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#LONGBLOB + */ +public final class LongBlob { + + /** Prevent instantiation. */ + private LongBlob() { + } + + /** + * Returns the {@code LONGBLOB} column type. + * + * @return a {@link ColumnType} representing {@code LONGBLOB} + */ + public static ColumnType of() { + return ColumnType.LONGBLOB; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongText.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongText.java new file mode 100644 index 0000000..30f69eb --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/LongText.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code LONGTEXT} (up to 4 GB; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#LONGTEXT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("document", LongText.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#LONGTEXT + */ +public final class LongText { + + /** Prevent instantiation. */ + private LongText() { + } + + /** + * Returns the {@code LONGTEXT} column type. + * + * @return a {@link ColumnType} representing {@code LONGTEXT} + */ + public static ColumnType of() { + return ColumnType.LONGTEXT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumBlob.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumBlob.java new file mode 100644 index 0000000..f9058e8 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumBlob.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code MEDIUMBLOB} (up to 16 MB; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#MEDIUMBLOB}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("thumbnail", MediumBlob.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#MEDIUMBLOB + */ +public final class MediumBlob { + + /** Prevent instantiation. */ + private MediumBlob() { + } + + /** + * Returns the {@code MEDIUMBLOB} column type. + * + * @return a {@link ColumnType} representing {@code MEDIUMBLOB} + */ + public static ColumnType of() { + return ColumnType.MEDIUMBLOB; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumText.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumText.java new file mode 100644 index 0000000..7aef03d --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/MediumText.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code MEDIUMTEXT} (up to 16 MB; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#MEDIUMTEXT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("content", MediumText.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#MEDIUMTEXT + */ +public final class MediumText { + + /** Prevent instantiation. */ + private MediumText() { + } + + /** + * Returns the {@code MEDIUMTEXT} column type. + * + * @return a {@link ColumnType} representing {@code MEDIUMTEXT} + */ + public static ColumnType of() { + return ColumnType.MEDIUMTEXT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Numeric.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Numeric.java new file mode 100644 index 0000000..06638c3 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Numeric.java @@ -0,0 +1,36 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code NUMERIC(precision, scale)}. + * + *

Equivalent to {@link Decimal} in most databases. Delegates to + * {@link ColumnType#numeric(int, int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("amount", Numeric.of(15, 4).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#numeric(int, int) + */ +public final class Numeric { + + /** Prevent instantiation. */ + private Numeric() { + } + + /** + * Returns the {@code NUMERIC(precision, scale)} column type. + * + * @param precision total number of significant digits; must be positive + * @param scale number of digits after the decimal point; must be ≥ 0 + * @return a {@link ColumnType} representing {@code NUMERIC(precision, scale)} + */ + public static ColumnType of(final int precision, final int scale) { + return ColumnType.numeric(precision, scale); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Real.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Real.java new file mode 100644 index 0000000..bc4495c --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Real.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code REAL} (standard SQL double-precision alias). + * + *

Delegates to {@link ColumnType#REAL}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("weight", Real.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#REAL + */ +public final class Real { + + /** Prevent instantiation. */ + private Real() { + } + + /** + * Returns the {@code REAL} column type. + * + * @return a {@link ColumnType} representing {@code REAL} + */ + public static ColumnType of() { + return ColumnType.REAL; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Serial.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Serial.java new file mode 100644 index 0000000..fdf8b7d --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Serial.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code SERIAL} (auto-incrementing 4-byte integer; PostgreSQL). + * + *

Delegates to {@link ColumnType#SERIAL}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("id", Serial.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#SERIAL + */ +public final class Serial { + + /** Prevent instantiation. */ + private Serial() { + } + + /** + * Returns the {@code SERIAL} column type. + * + * @return a {@link ColumnType} representing {@code SERIAL} + */ + public static ColumnType of() { + return ColumnType.SERIAL; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SmallInt.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SmallInt.java new file mode 100644 index 0000000..a6a808f --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SmallInt.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code SMALLINT}. + * + *

Delegates to {@link ColumnType#SMALLINT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("count", SmallInt.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#SMALLINT + */ +public final class SmallInt { + + /** Prevent instantiation. */ + private SmallInt() { + } + + /** + * Returns the {@code SMALLINT} column type. + * + * @return a {@link ColumnType} representing {@code SMALLINT} + */ + public static ColumnType of() { + return ColumnType.SMALLINT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlDouble.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlDouble.java new file mode 100644 index 0000000..e96986b --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlDouble.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code DOUBLE} (double-precision). + * + *

Named {@code SqlDouble} to avoid shadowing {@link java.lang.Double}. + * Delegates to {@link ColumnType#DOUBLE}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("latitude", SqlDouble.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#DOUBLE + */ +public final class SqlDouble { + + /** Prevent instantiation. */ + private SqlDouble() { + } + + /** + * Returns the {@code DOUBLE} column type. + * + * @return a {@link ColumnType} representing {@code DOUBLE} + */ + public static ColumnType of() { + return ColumnType.DOUBLE; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlFloat.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlFloat.java new file mode 100644 index 0000000..ff5a099 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/SqlFloat.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code FLOAT} (single-precision). + * + *

Named {@code SqlFloat} to avoid shadowing {@link java.lang.Float}. + * Delegates to {@link ColumnType#FLOAT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("score", SqlFloat.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#FLOAT + */ +public final class SqlFloat { + + /** Prevent instantiation. */ + private SqlFloat() { + } + + /** + * Returns the {@code FLOAT} column type. + * + * @return a {@link ColumnType} representing {@code FLOAT} + */ + public static ColumnType of() { + return ColumnType.FLOAT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Text.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Text.java new file mode 100644 index 0000000..4a8bb54 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Text.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TEXT} (unbounded character string). + * + *

Delegates to {@link ColumnType#TEXT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("body", Text.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TEXT + */ +public final class Text { + + /** Prevent instantiation. */ + private Text() { + } + + /** + * Returns the {@code TEXT} column type. + * + * @return a {@link ColumnType} representing {@code TEXT} + */ + public static ColumnType of() { + return ColumnType.TEXT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Time.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Time.java new file mode 100644 index 0000000..b7b5991 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Time.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TIME} (time-of-day without date). + * + *

Delegates to {@link ColumnType#TIME}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("start_time", Time.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TIME + */ +public final class Time { + + /** Prevent instantiation. */ + private Time() { + } + + /** + * Returns the {@code TIME} column type. + * + * @return a {@link ColumnType} representing {@code TIME} + */ + public static ColumnType of() { + return ColumnType.TIME; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Timestamp.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Timestamp.java new file mode 100644 index 0000000..ff70814 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Timestamp.java @@ -0,0 +1,47 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TIMESTAMP} and {@code TIMESTAMP(p)}. + * + *

Delegates to {@link ColumnType#TIMESTAMP} (no-arg) or + * {@link ColumnType#timestamp(int)} (with fractional-seconds precision). + * Use modifier methods on the returned {@link ColumnType} to append + * column-level constraints:

+ * + *
{@code
+ * .column("created_at", Timestamp.of())
+ * .column("updated_at", Timestamp.of(3).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TIMESTAMP + * @see ColumnType#timestamp(int) + */ +public final class Timestamp { + + /** Prevent instantiation. */ + private Timestamp() { + } + + /** + * Returns the {@code TIMESTAMP} column type without fractional-seconds precision. + * + * @return a {@link ColumnType} representing {@code TIMESTAMP} + */ + public static ColumnType of() { + return ColumnType.TIMESTAMP; + } + + /** + * Returns the {@code TIMESTAMP(precision)} column type. + * + * @param precision number of fractional-seconds digits (0–6) + * @return a {@link ColumnType} representing {@code TIMESTAMP(precision)} + */ + public static ColumnType of(final int precision) { + return ColumnType.timestamp(precision); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyBlob.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyBlob.java new file mode 100644 index 0000000..0ecf7e3 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyBlob.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TINYBLOB} (up to 255 bytes; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#TINYBLOB}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("icon", TinyBlob.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TINYBLOB + */ +public final class TinyBlob { + + /** Prevent instantiation. */ + private TinyBlob() { + } + + /** + * Returns the {@code TINYBLOB} column type. + * + * @return a {@link ColumnType} representing {@code TINYBLOB} + */ + public static ColumnType of() { + return ColumnType.TINYBLOB; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyInt.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyInt.java new file mode 100644 index 0000000..0d1a258 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyInt.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TINYINT}. + * + *

Delegates to {@link ColumnType#TINYINT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("flag", TinyInt.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TINYINT + */ +public final class TinyInt { + + /** Prevent instantiation. */ + private TinyInt() { + } + + /** + * Returns the {@code TINYINT} column type. + * + * @return a {@link ColumnType} representing {@code TINYINT} + */ + public static ColumnType of() { + return ColumnType.TINYINT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyText.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyText.java new file mode 100644 index 0000000..b925e0f --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/TinyText.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code TINYTEXT} (up to 255 characters; MySQL / MariaDB). + * + *

Delegates to {@link ColumnType#TINYTEXT}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("note", TinyText.of())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#TINYTEXT + */ +public final class TinyText { + + /** Prevent instantiation. */ + private TinyText() { + } + + /** + * Returns the {@code TINYTEXT} column type. + * + * @return a {@link ColumnType} representing {@code TINYTEXT} + */ + public static ColumnType of() { + return ColumnType.TINYTEXT; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Uuid.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Uuid.java new file mode 100644 index 0000000..bedceb7 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/Uuid.java @@ -0,0 +1,33 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code UUID} (universally unique identifier). + * + *

Delegates to {@link ColumnType#UUID}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("id", Uuid.of().notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#UUID + */ +public final class Uuid { + + /** Prevent instantiation. */ + private Uuid() { + } + + /** + * Returns the {@code UUID} column type. + * + * @return a {@link ColumnType} representing {@code UUID} + */ + public static ColumnType of() { + return ColumnType.UUID; + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarBinary.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarBinary.java new file mode 100644 index 0000000..315ff97 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarBinary.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code VARBINARY(length)} (variable-length binary string). + * + *

Delegates to {@link ColumnType#varBinary(int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("token", VarBinary.of(128).notNull())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#varBinary(int) + */ +public final class VarBinary { + + /** Prevent instantiation. */ + private VarBinary() { + } + + /** + * Returns the {@code VARBINARY(length)} column type. + * + * @param length maximum number of bytes; must be positive + * @return a {@link ColumnType} representing {@code VARBINARY(length)} + */ + public static ColumnType of(final int length) { + return ColumnType.varBinary(length); + } +} diff --git a/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarChar.java b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarChar.java new file mode 100644 index 0000000..6094460 --- /dev/null +++ b/src/main/java/com/github/ezframework/javaquerybuilder/query/builder/col/VarChar.java @@ -0,0 +1,34 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; + +/** + * Column type shorthand for {@code VARCHAR(length)}. + * + *

Delegates to {@link ColumnType#varChar(int)}. Use modifier methods on the + * returned {@link ColumnType} to append column-level constraints:

+ * + *
{@code
+ * .column("username", VarChar.of(64).notNull().unique())
+ * }
+ * + * @author EzFramework + * @version 1.1.0 + * @see ColumnType#varChar(int) + */ +public final class VarChar { + + /** Prevent instantiation. */ + private VarChar() { + } + + /** + * Returns the {@code VARCHAR(length)} column type. + * + * @param length maximum number of characters; must be positive + * @return a {@link ColumnType} representing {@code VARCHAR(length)} + */ + public static ColumnType of(final int length) { + return ColumnType.varChar(length); + } +} diff --git a/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/col/ColTypesTest.java b/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/col/ColTypesTest.java new file mode 100644 index 0000000..65df97e --- /dev/null +++ b/src/test/java/com/github/ezframework/javaquerybuilder/query/builder/col/ColTypesTest.java @@ -0,0 +1,199 @@ +package com.github.ezframework.javaquerybuilder.query.builder.col; + +import com.github.ezframework.javaquerybuilder.query.builder.ColumnType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ColTypesTest { + + // ── Fixed integer types ─────────────────────────────────────────────── + + @Test + void tinyIntReturnsTinyint() { + assertEquals("TINYINT", TinyInt.of().toSql()); + } + + @Test + void smallIntReturnsSmallint() { + assertEquals("SMALLINT", SmallInt.of().toSql()); + } + + @Test + void intReturnsInt() { + assertEquals("INT", Int.of().toSql()); + } + + @Test + void bigIntReturnsBigint() { + assertEquals("BIGINT", BigInt.of().toSql()); + } + + // ── Fixed floating-point types ──────────────────────────────────────── + + @Test + void sqlFloatReturnsFloat() { + assertEquals("FLOAT", SqlFloat.of().toSql()); + } + + @Test + void sqlDoubleReturnsDouble() { + assertEquals("DOUBLE", SqlDouble.of().toSql()); + } + + @Test + void realReturnsReal() { + assertEquals("REAL", Real.of().toSql()); + } + + // ── Boolean ─────────────────────────────────────────────────────────── + + @Test + void boolReturnsBoolean() { + assertEquals("BOOLEAN", Bool.of().toSql()); + } + + // ── Fixed text types ────────────────────────────────────────────────── + + @Test + void textReturnsText() { + assertEquals("TEXT", Text.of().toSql()); + } + + @Test + void tinyTextReturnsTinytext() { + assertEquals("TINYTEXT", TinyText.of().toSql()); + } + + @Test + void mediumTextReturnsMediumtext() { + assertEquals("MEDIUMTEXT", MediumText.of().toSql()); + } + + @Test + void longTextReturnsLongtext() { + assertEquals("LONGTEXT", LongText.of().toSql()); + } + + @Test + void clobReturnsClob() { + assertEquals("CLOB", Clob.of().toSql()); + } + + // ── Binary types ────────────────────────────────────────────────────── + + @Test + void blobReturnsBlob() { + assertEquals("BLOB", Blob.of().toSql()); + } + + @Test + void tinyBlobReturnsTinyblob() { + assertEquals("TINYBLOB", TinyBlob.of().toSql()); + } + + @Test + void mediumBlobReturnsMediumblob() { + assertEquals("MEDIUMBLOB", MediumBlob.of().toSql()); + } + + @Test + void longBlobReturnsLongblob() { + assertEquals("LONGBLOB", LongBlob.of().toSql()); + } + + // ── Date / time types ───────────────────────────────────────────────── + + @Test + void dateReturnsDate() { + assertEquals("DATE", Date.of().toSql()); + } + + @Test + void timeReturnsTime() { + assertEquals("TIME", Time.of().toSql()); + } + + @Test + void dateTimeReturnsDatetime() { + assertEquals("DATETIME", DateTime.of().toSql()); + } + + @Test + void timestampNoArgReturnsTimestamp() { + assertEquals("TIMESTAMP", Timestamp.of().toSql()); + } + + @Test + void timestampWithPrecisionReturnsPrecision() { + assertEquals("TIMESTAMP(3)", Timestamp.of(3).toSql()); + } + + // ── Miscellaneous types ─────────────────────────────────────────────── + + @Test + void jsonReturnsJson() { + assertEquals("JSON", Json.of().toSql()); + } + + @Test + void serialReturnsSerial() { + assertEquals("SERIAL", Serial.of().toSql()); + } + + @Test + void bigSerialReturnsBigserial() { + assertEquals("BIGSERIAL", BigSerial.of().toSql()); + } + + @Test + void uuidReturnsUuid() { + assertEquals("UUID", Uuid.of().toSql()); + } + + // ── Parameterised types ─────────────────────────────────────────────── + + @Test + void varCharBuildsCorrectSql() { + assertEquals("VARCHAR(64)", VarChar.of(64).toSql()); + } + + @Test + void charBuildsCorrectSql() { + assertEquals("CHAR(2)", Char.of(2).toSql()); + } + + @Test + void decimalBuildsCorrectSql() { + assertEquals("DECIMAL(10, 2)", Decimal.of(10, 2).toSql()); + } + + @Test + void numericBuildsCorrectSql() { + assertEquals("NUMERIC(15, 4)", Numeric.of(15, 4).toSql()); + } + + @Test + void binaryBuildsCorrectSql() { + assertEquals("BINARY(32)", Binary.of(32).toSql()); + } + + @Test + void varBinaryBuildsCorrectSql() { + assertEquals("VARBINARY(128)", VarBinary.of(128).toSql()); + } + + // ── Modifier chaining ───────────────────────────────────────────────── + + @Test + void modifiersChainOnColType() { + final ColumnType result = Int.of().notNull().autoIncrement(); + assertEquals("INT NOT NULL AUTO_INCREMENT", result.toSql()); + } + + @Test + void varCharWithModifiers() { + final ColumnType result = VarChar.of(64).notNull().unique(); + assertEquals("VARCHAR(64) NOT NULL UNIQUE", result.toSql()); + } +} From 68f8a2dcfa256fbf34aa3780e374c69bc6bfef06 Mon Sep 17 00:00:00 2001 From: ez-plugins Date: Wed, 22 Apr 2026 23:05:04 +0200 Subject: [PATCH 5/5] fix(docs): resolve MD060 table-column-style lint violations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add spaces to all table separator rows (|---|---| → | --- | --- |) across all 19 docs files to satisfy markdownlint MD060 compact style - Remove orphan duplicate row at end of docs/queries/create.md --- docs/api-reference.md | 44 ++++++++++++++++++------------------- docs/conditions.md | 10 ++++----- docs/configuration.md | 10 ++++----- docs/dialects/index.md | 8 +++---- docs/dialects/mysql.md | 2 +- docs/dialects/postgresql.md | 2 +- docs/dialects/sqlite.md | 2 +- docs/dialects/standard.md | 2 +- docs/exceptions.md | 6 ++--- docs/in-memory.md | 2 +- docs/index.md | 2 +- docs/installation.md | 2 +- docs/queries/create.md | 10 ++++----- docs/queries/delete.md | 2 +- docs/queries/index.md | 4 ++-- docs/queries/insert.md | 2 +- docs/queries/select.md | 2 +- docs/queries/update.md | 2 +- docs/subqueries.md | 2 +- 19 files changed, 57 insertions(+), 59 deletions(-) diff --git a/docs/api-reference.md b/docs/api-reference.md index a1cae1f..c1635fa 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -24,7 +24,7 @@ Main entry point for SELECT queries and static gateway to DML builders. **Static factory methods** | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `insert()` | `InsertBuilder` | New `InsertBuilder` | | `insertInto(String table)` | `InsertBuilder` | New `InsertBuilder` pre-set to `table` | | `update()` | `UpdateBuilder` | New `UpdateBuilder` | @@ -37,7 +37,7 @@ Main entry point for SELECT queries and static gateway to DML builders. **SELECT builder methods** | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `from(String table)` | `QueryBuilder` | Set source table | | `select(String... columns)` | `QueryBuilder` | Add columns to SELECT clause; omit for `SELECT *` | | `distinct()` | `QueryBuilder` | Add `DISTINCT` to SELECT | @@ -82,7 +82,7 @@ Main entry point for SELECT queries and static gateway to DML builders. Lower-level SELECT builder that produces `SqlResult` directly (no `Query` intermediary). | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `from(String table)` | `SelectBuilder` | Set source table | | `select(String... columns)` | `SelectBuilder` | Add SELECT columns | | `distinct()` | `SelectBuilder` | Add `DISTINCT` | @@ -102,7 +102,7 @@ Lower-level SELECT builder that produces `SqlResult` directly (no `Query` interm ### `InsertBuilder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `into(String table)` | `InsertBuilder` | Set target table | | `value(String col, Object val)` | `InsertBuilder` | Add a column/value pair | | `build()` | `SqlResult` | Render with standard dialect | @@ -113,7 +113,7 @@ Lower-level SELECT builder that produces `SqlResult` directly (no `Query` interm ### `UpdateBuilder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `table(String table)` | `UpdateBuilder` | Set target table | | `set(String col, Object val)` | `UpdateBuilder` | Add a SET pair | | `whereEquals(col, val)` | `UpdateBuilder` | `WHERE col = ?` (AND) | @@ -127,7 +127,7 @@ Lower-level SELECT builder that produces `SqlResult` directly (no `Query` interm ### `DeleteBuilder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `from(String table)` | `DeleteBuilder` | Set target table | | `whereEquals(col, val)` | `DeleteBuilder` | `WHERE col = ?` (AND) | | `whereNotEquals(col, val)` | `DeleteBuilder` | `WHERE col != ?` (AND) | @@ -147,7 +147,7 @@ Lower-level SELECT builder that produces `SqlResult` directly (no `Query` interm ### `CreateBuilder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `table(String name)` | `CreateBuilder` | Set table name | | `column(String name, String sqlType)` | `CreateBuilder` | Add column definition | | `primaryKey(String name)` | `CreateBuilder` | Declare a primary key column | @@ -164,7 +164,7 @@ Lower-level SELECT builder that produces `SqlResult` directly (no `Query` interm Enum of comparison operators. See [Conditions](conditions) for the full table. | Constant | SQL | -|----------|-----| +| ---------- | ----- | | `EQ` | `= ?` | | `NEQ` | `!= ?` | | `GT` | `> ?` | @@ -187,7 +187,7 @@ Enum of comparison operators. See [Conditions](conditions) for the full table. ### `Condition` | Member | Description | -|--------|-------------| +| -------- | ------------- | | `Condition(Operator op, Object value)` | Create a condition; `value` may be `null` | | `getOperator()` | Returns the `Operator` | | `getValue()` | Returns the comparison value (`null`, scalar, `List`, or `Query`) | @@ -198,7 +198,7 @@ Enum of comparison operators. See [Conditions](conditions) for the full table. ### `ConditionEntry` | Member | Description | -|--------|-------------| +| -------- | ------------- | | `ConditionEntry(String col, Condition cond, Connector connector)` | Create a condition entry | | `getColumn()` | Column name (`null` for EXISTS-subquery conditions) | | `getCondition()` | The wrapped `Condition` | @@ -209,7 +209,7 @@ Enum of comparison operators. See [Conditions](conditions) for the full table. ### `Connector` | Constant | SQL keyword | -|----------|-------------| +| ---------- | ------------- | | `AND` | `AND` | | `OR` | `OR` | @@ -223,7 +223,7 @@ Immutable data holder produced by `QueryBuilder.build()`. All fields have getters and setters; setters are used exclusively by the builders. | Getter | Type | Description | -|--------|------|-------------| +| -------- | ------ | ------------- | | `getTable()` | `String` | Source table name | | `getSelectColumns()` | `List` | Columns in SELECT clause; empty = `SELECT *` | | `isDistinct()` | `boolean` | Whether `DISTINCT` is active | @@ -244,7 +244,7 @@ getters and setters; setters are used exclusively by the builders. ### `JoinClause` | Member | Description | -|--------|-------------| +| -------- | ------------- | | `JoinClause(Type, String table, String on)` | Plain-table join | | `JoinClause(Type, Query subquery, String alias, String on)` | Subquery (derived-table) join | | `getType()` | `JoinClause.Type`: `INNER`, `LEFT`, `RIGHT`, or `CROSS` | @@ -258,7 +258,7 @@ getters and setters; setters are used exclusively by the builders. ### `ScalarSelectItem` | Member | Description | -|--------|-------------| +| -------- | ------------- | | `ScalarSelectItem(Query subquery, String alias)` | Create a scalar SELECT item | | `getSubquery()` | The subquery to embed | | `getAlias()` | Column alias in SELECT clause | @@ -283,7 +283,7 @@ public interface QueryableStorage { ### `SqlDialect` | Member | Description | -|--------|-------------| +| -------- | ------------- | | `STANDARD` | ANSI SQL (no identifier quoting) | | `MYSQL` | MySQL: back-tick quoting; DELETE LIMIT supported | | `SQLITE` | SQLite: double-quote quoting; DELETE LIMIT supported | @@ -295,7 +295,7 @@ public interface QueryableStorage { ### `SqlResult` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `getSql()` | `String` | Rendered SQL with `?` placeholders | | `getParameters()` | `List` | Bind parameters in placeholder order | @@ -311,7 +311,7 @@ usage guide. **Static methods** | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `global()` | `QueryBuilderDefaults` | Current JVM-wide defaults instance | | `setGlobal(defaults)` | `void` | Replace the JVM-wide defaults; throws `NullPointerException` if `null` | | `builder()` | `Builder` | New builder pre-filled with canonical defaults | @@ -320,7 +320,7 @@ usage guide. **Instance getters** | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `getDialect()` | `SqlDialect` | Configured SQL dialect | | `getDefaultColumns()` | `String` | Default SELECT column expression | | `getDefaultLimit()` | `int` | Default LIMIT; `-1` means none | @@ -333,7 +333,7 @@ usage guide. ### `QueryBuilderDefaults.Builder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `dialect(SqlDialect)` | `Builder` | Set dialect; throws `NullPointerException` if `null` | | `defaultColumns(String)` | `Builder` | Set default SELECT columns; throws `NullPointerException` if `null` | | `defaultLimit(int)` | `Builder` | Set default LIMIT; pass `-1` to disable | @@ -349,7 +349,7 @@ usage guide. ### `QueryBuilderException` | Constructor | Description | -|-------------|-------------| +| ------------- | ------------- | | `QueryBuilderException()` | No-message default | | `QueryBuilderException(String message)` | Simple message | | `QueryBuilderException(String message, Throwable cause)` | Wraps another exception | @@ -360,7 +360,7 @@ usage guide. ### `QueryException` | Constructor | Description | -|-------------|-------------| +| ------------- | ------------- | | `QueryException()` | No-message default | | `QueryException(String message)` | Simple message | | `QueryException(String message, Throwable cause)` | Wraps another exception | @@ -371,7 +371,7 @@ usage guide. ### `QueryRenderException` | Constructor | Description | -|-------------|-------------| +| ------------- | ------------- | | `QueryRenderException()` | No-message default | | `QueryRenderException(String message)` | Simple message | | `QueryRenderException(String message, Throwable cause)` | Wraps another exception | diff --git a/docs/conditions.md b/docs/conditions.md index 8d08cf6..c7c9566 100644 --- a/docs/conditions.md +++ b/docs/conditions.md @@ -33,7 +33,7 @@ conditions use `AND` by default; call the `orWhere*` variant to use `OR`. `Operator` is the single source of truth for all supported comparison operators. | Constant | SQL rendering | Notes | -|----------|---------------|-------| +| ---------- | --------------- | ------- | | `EQ` | `col = ?` | Equality | | `NEQ` | `col != ?` | Not equal | | `GT` | `col > ?` | Greater than | @@ -61,7 +61,7 @@ The table below maps every `QueryBuilder` `where*` method to its `Operator` constant and the SQL it generates. | Builder method | Operator | Generated SQL fragment | -|----------------|----------|------------------------| +| ---------------- | ---------- | ------------------------ | | `whereEquals(col, val)` | `EQ` | `col = ?` | | `orWhereEquals(col, val)` | `EQ` | `OR col = ?` | | `whereNotEquals(col, val)` | `NEQ` | `col != ?` | @@ -131,7 +131,7 @@ new QueryBuilder() `Condition` pairs an `Operator` with its comparison value. | Member | Type | Description | -|--------|------|-------------| +| -------- | ------ | ------------- | | `Condition(Operator op, Object value)` | constructor | Create a condition; `value` may be `null` for `IS_NULL`, `IS_NOT_NULL`, `EXISTS` | | `getOperator()` | `Operator` | The operator for this condition | | `getValue()` | `Object` | The comparison value (`null`, scalar, `List`, or `Query`) | @@ -147,7 +147,7 @@ without a database. `ConditionEntry` wraps a `Condition` with its column name and `Connector`. | Member | Type | Description | -|--------|------|-------------| +| -------- | ------ | ------------- | | `ConditionEntry(String column, Condition condition, Connector connector)` | constructor | Create a condition entry | | `getColumn()` | `String` | The column name (`null` for `EXISTS_SUBQUERY` / `NOT_EXISTS_SUBQUERY`) | | `getCondition()` | `Condition` | The wrapped condition | @@ -158,6 +158,6 @@ without a database. ## Connector enum | Constant | SQL keyword | -|----------|-------------| +| ---------- | ------------- | | `AND` | `AND` | | `OR` | `OR` | diff --git a/docs/configuration.md b/docs/configuration.md index c82296a..05218f0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -28,7 +28,7 @@ defaults for a single builder instance using `.withDefaults()`. **Configurable settings:** | Setting | Default | Description | -|---------|---------|-------------| +| --------- | --------- | ------------- | | `dialect` | `SqlDialect.STANDARD` | SQL dialect used for identifier quoting | | `defaultColumns` | `"*"` | Column expression used in `SELECT` when none are specified | | `defaultLimit` | `-1` (no limit) | `LIMIT` applied when the builder has no `.limit()` call | @@ -165,7 +165,7 @@ QueryBuilderDefaults.setGlobal(QueryBuilderDefaults.builder().build()); ### `QueryBuilderDefaults` (static methods) | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `global()` | `QueryBuilderDefaults` | The current JVM-wide defaults instance | | `setGlobal(defaults)` | `void` | Replace the JVM-wide defaults; throws `NullPointerException` if `null` | | `builder()` | `Builder` | New builder pre-filled with canonical defaults | @@ -174,7 +174,7 @@ QueryBuilderDefaults.setGlobal(QueryBuilderDefaults.builder().build()); ### `QueryBuilderDefaults` (instance getters) | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `getDialect()` | `SqlDialect` | The configured SQL dialect | | `getDefaultColumns()` | `String` | Default SELECT column expression | | `getDefaultLimit()` | `int` | Default LIMIT value; `-1` means none | @@ -185,7 +185,7 @@ QueryBuilderDefaults.setGlobal(QueryBuilderDefaults.builder().build()); ### `QueryBuilderDefaults.Builder` | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `dialect(SqlDialect)` | `Builder` | Set dialect; throws `NullPointerException` if `null` | | `defaultColumns(String)` | `Builder` | Set default SELECT columns; throws `NullPointerException` if `null` | | `defaultLimit(int)` | `Builder` | Set default LIMIT; pass `-1` to disable | @@ -199,7 +199,7 @@ QueryBuilderDefaults.setGlobal(QueryBuilderDefaults.builder().build()); All three builders throw `NullPointerException` if `null` is passed. | Builder | Method signature | -|---------|-----------------| +| --------- | ----------------- | | `QueryBuilder` | `withDefaults(QueryBuilderDefaults defaults)` | | `SelectBuilder` | `withDefaults(QueryBuilderDefaults defaults)` | | `DeleteBuilder` | `withDefaults(QueryBuilderDefaults defaults)` | diff --git a/docs/dialects/index.md b/docs/dialects/index.md index 35b1483..0ecab81 100644 --- a/docs/dialects/index.md +++ b/docs/dialects/index.md @@ -24,7 +24,7 @@ parameterized `SqlResult`. Four built-in dialects are provided as constants on the interface: | Constant | Page | Identifier quoting | DELETE LIMIT | ILIKE | RETURNING | -|----------|------|--------------------|--------------|-------|-----------| +| ---------- | ------ | -------------------- | -------------- | ------- | ----------- | | `SqlDialect.STANDARD` | [STANDARD]({{ site.baseurl }}/sql-dialects/standard/) | None (ANSI) | No | No | No | | `SqlDialect.MYSQL` | [MySQL]({{ site.baseurl }}/sql-dialects/mysql/) | Back-tick `` ` `` | Yes | No | No | | `SqlDialect.SQLITE` | [SQLite]({{ site.baseurl }}/sql-dialects/sqlite/) | Double-quote `"` | Yes | No | No | @@ -38,7 +38,7 @@ The same `Query` produces different SQL across dialects due to identifier quoting: | Feature | STANDARD | MYSQL | SQLITE | POSTGRESQL | -|---------|----------|-------|--------|------------| +| --------- | ---------- | ------- | -------- | ------------ | | Table quoting | `users` | `` `users` `` | `"users"` | `"users"` | | Column quoting | `id` | `` `id` `` | `"id"` | `"id"` | | DELETE LIMIT | No | Yes | Yes | No | @@ -54,7 +54,7 @@ quoting: rendered SQL string and the ordered bind-parameter list. | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `getSql()` | `String` | The rendered SQL with `?` placeholders | | `getParameters()` | `List` | Bind parameters in the order they appear in the SQL | @@ -97,7 +97,7 @@ and `appendConditionFragment`. ## SqlDialect interface | Member | Description | -|--------|-------------| +| -------- | ------------- | | `SqlDialect.STANDARD` | ANSI SQL constant instance | | `SqlDialect.MYSQL` | MySQL dialect constant instance | | `SqlDialect.SQLITE` | SQLite dialect constant instance | diff --git a/docs/dialects/mysql.md b/docs/dialects/mysql.md index b375e01..d664bd7 100644 --- a/docs/dialects/mysql.md +++ b/docs/dialects/mysql.md @@ -24,7 +24,7 @@ description: "MySQL dialect — back-tick identifier quoting and DELETE LIMIT su Quoting is applied to SELECT and DELETE queries rendered through this dialect. | Feature | Value | -|---------|-------| +| --------- | ------- | | Identifier quoting | Back-tick `` ` `` | | DELETE LIMIT | Supported | | ILIKE | Not supported | diff --git a/docs/dialects/postgresql.md b/docs/dialects/postgresql.md index c4d56e9..a9abb9f 100644 --- a/docs/dialects/postgresql.md +++ b/docs/dialects/postgresql.md @@ -24,7 +24,7 @@ and adds two PostgreSQL-specific features: case-insensitive `ILIKE` / `NOT ILIKE operators on SELECT queries, and a `RETURNING` clause on `DELETE` statements. | Feature | Value | -|---------|-------| +| --------- | ------- | | Identifier quoting | Double-quote `"` | | DELETE LIMIT | Not supported | | ILIKE / NOT ILIKE | Supported | diff --git a/docs/dialects/sqlite.md b/docs/dialects/sqlite.md index 5247cba..6c1434c 100644 --- a/docs/dialects/sqlite.md +++ b/docs/dialects/sqlite.md @@ -24,7 +24,7 @@ description: "SQLite dialect — double-quote identifier quoting and DELETE LIMI supports the `LIMIT` clause on `DELETE` statements. | Feature | Value | -|---------|-------| +| --------- | ------- | | Identifier quoting | Double-quote `"` | | DELETE LIMIT | Supported | | ILIKE | Not supported | diff --git a/docs/dialects/standard.md b/docs/dialects/standard.md index ae27da7..b0eebc9 100644 --- a/docs/dialects/standard.md +++ b/docs/dialects/standard.md @@ -24,7 +24,7 @@ It is the default dialect used by `buildSql()` and `build()` when no dialect is specified. | Feature | Value | -|---------|-------| +| --------- | ------- | | Identifier quoting | None | | DELETE LIMIT | Not supported | | ILIKE | Not supported | diff --git a/docs/exceptions.md b/docs/exceptions.md index ea56e14..34d9f9a 100644 --- a/docs/exceptions.md +++ b/docs/exceptions.md @@ -47,7 +47,7 @@ try { **Constructors:** | Constructor | Use case | -|-------------|----------| +| ------------- | ---------- | | `QueryBuilderException()` | No-message default | | `QueryBuilderException(String message)` | Simple message | | `QueryBuilderException(String message, Throwable cause)` | Wraps another exception | @@ -72,7 +72,7 @@ try { **Constructors:** | Constructor | Use case | -|-------------|----------| +| ------------- | ---------- | | `QueryException()` | No-message default | | `QueryException(String message)` | Simple message | | `QueryException(String message, Throwable cause)` | Wraps another exception | @@ -96,7 +96,7 @@ try { **Constructors:** | Constructor | Use case | -|-------------|----------| +| ------------- | ---------- | | `QueryRenderException()` | No-message default | | `QueryRenderException(String message)` | Simple message | | `QueryRenderException(String message, Throwable cause)` | Wraps another exception | diff --git a/docs/in-memory.md b/docs/in-memory.md index 83236aa..9d84a03 100644 --- a/docs/in-memory.md +++ b/docs/in-memory.md @@ -149,7 +149,7 @@ List ids = store.query(q); `Condition.matches` evaluates the following operators against an attribute map: | Operator | In-memory behaviour | -|----------|---------------------| +| ---------- | --------------------- | | `EQ` | `Objects.equals(stored, value)` | | `NEQ` | `!Objects.equals(stored, value)` | | `GT` / `GTE` / `LT` / `LTE` | Numeric comparison; coerces `Long`/`Integer`/`Double` as needed | diff --git a/docs/index.md b/docs/index.md index bfa3ed8..513b2dc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -100,7 +100,7 @@ SqlResult update = QueryBuilder.update("users") ## Documentation | Page | What it covers | -|------|----------------| +| ------ | ---------------- | | [Installation](installation) | Maven, Gradle, JitPack, GitHub Packages | | [Queries]({{ site.baseurl }}/queries/) | SELECT, INSERT, UPDATE, DELETE, CREATE TABLE builders | | [Conditions](conditions) | All 18 operators, `Condition`, `ConditionEntry`, `Connector` | diff --git a/docs/installation.md b/docs/installation.md index 0dbb5b8..531d646 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -18,7 +18,7 @@ description: "Add JavaQueryBuilder to your Java project via JitPack or GitHub Pa ## Requirements | Requirement | Minimum version | -|-------------|----------------| +| ------------- | ---------------- | | Java | **25** | | Build tool | Maven **3.8+** or Gradle **8+** | diff --git a/docs/queries/create.md b/docs/queries/create.md index 1c9651b..f440719 100644 --- a/docs/queries/create.md +++ b/docs/queries/create.md @@ -55,7 +55,7 @@ constraints. ### Fixed-width types | Constant | SQL | Notes | -|----------|-----|-------| +| ---------- | ----- | ------- | | `ColumnType.TINYINT` | `TINYINT` | 1-byte integer; MySQL / MariaDB | | `ColumnType.SMALLINT` | `SMALLINT` | 2-byte integer | | `ColumnType.INT` | `INT` | 4-byte integer | @@ -86,7 +86,7 @@ constraints. ### Parameterised factory methods | Method | SQL output | Description | -|--------|-----------|-------------| +| -------- | ----------- | ------------- | | `ColumnType.varChar(n)` | `VARCHAR(n)` | Variable-length string up to `n` chars | | `ColumnType.charType(n)` | `CHAR(n)` | Fixed-length string of `n` chars | | `ColumnType.decimal(p, s)` | `DECIMAL(p, s)` | Exact decimal with `p` total and `s` fraction digits | @@ -100,7 +100,7 @@ constraints. Modifiers return a new `ColumnType` instance and can be chained in any order: | Method | Appends | Example | -|--------|---------|---------| +| -------- | --------- | --------- | | `.notNull()` | `NOT NULL` | `ColumnType.INT.notNull()` → `INT NOT NULL` | | `.unique()` | `UNIQUE` | `ColumnType.varChar(64).unique()` → `VARCHAR(64) UNIQUE` | | `.autoIncrement()` | `AUTO_INCREMENT` | `ColumnType.INT.notNull().autoIncrement()` → `INT NOT NULL AUTO_INCREMENT` | @@ -164,7 +164,7 @@ SqlResult result = QueryBuilder.createTable("user_roles") ## Method reference | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `table(String name)` | `CreateBuilder` | Set table name | | `column(String name, String sqlType)` | `CreateBuilder` | Add a column with a raw SQL type string | | `column(String name, ColumnType type)` | `CreateBuilder` | Add a column with a type-safe `ColumnType` | @@ -172,5 +172,3 @@ SqlResult result = QueryBuilder.createTable("user_roles") | `ifNotExists()` | `CreateBuilder` | Add `IF NOT EXISTS` guard | | `build()` | `SqlResult` | Render; throws `IllegalStateException` if table or columns are missing | | `build(SqlDialect dialect)` | `SqlResult` | Render with specified dialect | - -| `build(SqlDialect dialect)` | `SqlResult` | Render with specified dialect | diff --git a/docs/queries/delete.md b/docs/queries/delete.md index 96077a5..720f6e8 100644 --- a/docs/queries/delete.md +++ b/docs/queries/delete.md @@ -133,7 +133,7 @@ SqlResult result = QueryBuilder.deleteFrom("users") ## Method reference | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `from(String table)` | `DeleteBuilder` | Set target table | | `whereEquals(col, val)` | `DeleteBuilder` | `WHERE col = ?` (AND) | | `whereNotEquals(col, val)` | `DeleteBuilder` | `WHERE col != ?` (AND) | diff --git a/docs/queries/index.md b/docs/queries/index.md index cb01afc..8d4b349 100644 --- a/docs/queries/index.md +++ b/docs/queries/index.md @@ -18,7 +18,7 @@ dedicated builder objects for DML and DDL statements. ## Statement types | Statement | Builder | Entry point | -|-----------|---------|-------------| +| ----------- | --------- | ------------- | | [SELECT]({{ site.baseurl }}/queries/select/) | `QueryBuilder` | `new QueryBuilder()` | | [INSERT]({{ site.baseurl }}/queries/insert/) | `InsertBuilder` | `QueryBuilder.insertInto(table)` | | [UPDATE]({{ site.baseurl }}/queries/update/) | `UpdateBuilder` | `QueryBuilder.update(table)` | @@ -32,7 +32,7 @@ dedicated builder objects for DML and DDL statements. Every builder returns a `SqlResult` from its `build()` or `buildSql()` method: | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `getSql()` | `String` | The rendered SQL with `?` placeholders | | `getParameters()` | `List` | Bind parameters in order of appearance | diff --git a/docs/queries/insert.md b/docs/queries/insert.md index d49e758..9604705 100644 --- a/docs/queries/insert.md +++ b/docs/queries/insert.md @@ -74,7 +74,7 @@ SqlResult result = QueryBuilder.insertInto("users") ## Method reference | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `into(String table)` | `InsertBuilder` | Set target table (also available via factory) | | `value(String col, Object val)` | `InsertBuilder` | Add a column/value pair | | `returning(String... cols)` | `InsertBuilder` | Append `RETURNING col1, col2, ...` (PostgreSQL only) | diff --git a/docs/queries/select.md b/docs/queries/select.md index 0670218..b4893f9 100644 --- a/docs/queries/select.md +++ b/docs/queries/select.md @@ -251,7 +251,7 @@ identifier-quoting differences across database targets. `QueryBuilder` also exposes methods for embedding subqueries: | Method | What it adds | -|--------|-------------| +| -------- | ------------- | | `whereInSubquery(col, subquery)` | `WHERE col IN (SELECT ...)` | | `whereEqualsSubquery(col, subquery)` | `WHERE col = (SELECT ...)` | | `whereExistsSubquery(subquery)` | `WHERE EXISTS (SELECT ...)` | diff --git a/docs/queries/update.md b/docs/queries/update.md index 360e925..486efc3 100644 --- a/docs/queries/update.md +++ b/docs/queries/update.md @@ -85,7 +85,7 @@ SqlResult result = QueryBuilder.update("users") ## Method reference | Method | Returns | Description | -|--------|---------|-------------| +| -------- | --------- | ------------- | | `table(String table)` | `UpdateBuilder` | Set target table | | `set(String col, Object val)` | `UpdateBuilder` | Add a SET column/value pair | | `whereEquals(String col, Object val)` | `UpdateBuilder` | `WHERE col = ?` (AND) | diff --git a/docs/subqueries.md b/docs/subqueries.md index 108e14b..b5e9c54 100644 --- a/docs/subqueries.md +++ b/docs/subqueries.md @@ -22,7 +22,7 @@ statement. Every subquery is represented as a `Query` object built by a nested `QueryBuilder` call. | Method | SQL produced | -|--------|-------------| +| -------- | ------------- | | `whereInSubquery(col, sub)` | `WHERE col IN (SELECT ...)` | | `whereEqualsSubquery(col, sub)` | `WHERE col = (SELECT ...)` | | `whereExistsSubquery(sub)` | `WHERE EXISTS (SELECT ...)` |