mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-03 15:09:26 -05:00
schema added tiny, medium, long binary methods
- added a new schema constants for blob and bytea - fixed failing test after new changes - updated docs
This commit is contained in:
@@ -566,8 +566,10 @@ The schema builder blueprint offers a variety of methods that correspond to the
|
||||
[json](#column-method-json)
|
||||
[jsonb](#column-method-jsonb)
|
||||
[lineString](#column-method-lineString)
|
||||
[longBinary](#column-method-longBinary)
|
||||
[longText](#column-method-longText)
|
||||
[macAddress](#column-method-macAddress)
|
||||
[mediumBinary](#column-method-mediumBinary)
|
||||
[mediumIncrements](#column-method-mediumIncrements)
|
||||
[mediumInteger](#column-method-mediumInteger)
|
||||
[mediumText](#column-method-mediumText)
|
||||
@@ -591,6 +593,7 @@ The schema builder blueprint offers a variety of methods that correspond to the
|
||||
[timestampTz](#column-method-timestampTz)
|
||||
[timestampsTz](#column-method-timestampsTz)
|
||||
[timestamps](#column-method-timestamps)
|
||||
[tinyBinary](#column-method-tinyBinary)
|
||||
[tinyIncrements](#column-method-tinyIncrements)
|
||||
[tinyInteger](#column-method-tinyInteger)
|
||||
[tinyText](#column-method-tinyText)
|
||||
@@ -771,6 +774,12 @@ The `lineString` method creates a `LINESTRING` equivalent column:
|
||||
|
||||
table.lineString("positions");
|
||||
|
||||
#### `longBinary()` {#column-method-longBinary}
|
||||
|
||||
The `longBinary` method creates a `LONGBLOB` equivalent column:
|
||||
|
||||
table.longBinary("photo");
|
||||
|
||||
#### `longText()` {#column-method-longText}
|
||||
|
||||
The `longText` method creates a `LONGTEXT` equivalent column:
|
||||
@@ -783,6 +792,12 @@ The `macAddress` method creates a column that is intended to hold a MAC address.
|
||||
|
||||
table.macAddress("device");
|
||||
|
||||
#### `mediumBinary()` {#column-method-mediumBinary}
|
||||
|
||||
The `mediumBinary` method creates a `MEDIUMBLOB` equivalent column:
|
||||
|
||||
table.mediumBinary("photo");
|
||||
|
||||
#### `mediumIncrements()` {#column-method-mediumIncrements}
|
||||
|
||||
The `mediumIncrements` method creates an auto-incrementing `UNSIGNED MEDIUMINT` equivalent column as a primary key:
|
||||
@@ -923,6 +938,12 @@ The `timestamps` method creates `created_at` and `updated_at` `TIMESTAMP` equiva
|
||||
|
||||
table.timestamps(precision = 0);
|
||||
|
||||
#### `tinyBinary()` {#column-method-tinyBinary}
|
||||
|
||||
The `tinyBinary` method creates a `TINYBLOB` equivalent column:
|
||||
|
||||
table.tinyBinary("photo");
|
||||
|
||||
#### `tinyIncrements()` {#column-method-tinyIncrements}
|
||||
|
||||
The `tinyIncrements` method creates an auto-incrementing `UNSIGNED TINYINT` equivalent column as a primary key:
|
||||
|
||||
@@ -358,8 +358,14 @@ namespace Grammars
|
||||
/*! Create a new year column on the table. */
|
||||
ColumnDefinitionReference<> year(const QString &column);
|
||||
|
||||
/*! Create a new tiny binary column on the table. */
|
||||
ColumnDefinitionReference<> tinyBinary(const QString &column);
|
||||
/*! Create a new binary column on the table. */
|
||||
ColumnDefinitionReference<> binary(const QString &column);
|
||||
/*! Create a new medium binary column on the table. */
|
||||
ColumnDefinitionReference<> mediumBinary(const QString &column);
|
||||
/*! Create a new long binary column on the table. */
|
||||
ColumnDefinitionReference<> longBinary(const QString &column);
|
||||
|
||||
/*! Create a new uuid column on the table. */
|
||||
ColumnDefinitionReference<>
|
||||
|
||||
@@ -231,8 +231,14 @@ namespace Grammars
|
||||
QString typeTimestampTz(ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a year type. */
|
||||
QString typeYear(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a tiny binary type. */
|
||||
QString typeTinyBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a binary type. */
|
||||
QString typeBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a medium binary type. */
|
||||
QString typeMediumBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a long binary type. */
|
||||
QString typeLongBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a uuid type. */
|
||||
QString typeUuid(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for an IP address type. */
|
||||
|
||||
@@ -237,8 +237,14 @@ namespace Grammars
|
||||
QString typeTimestampTz(ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a year type. */
|
||||
QString typeYear(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a tiny binary type. */
|
||||
QString typeTinyBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a binary type. */
|
||||
QString typeBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a medium binary type. */
|
||||
QString typeMediumBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a long binary type. */
|
||||
QString typeLongBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a uuid type. */
|
||||
QString typeUuid(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for an IP address type. */
|
||||
|
||||
@@ -202,8 +202,14 @@ namespace Grammars
|
||||
QString typeTimestampTz(ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a year type. */
|
||||
QString typeYear(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a tiny binary type. */
|
||||
QString typeTinyBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a binary type. */
|
||||
QString typeBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a medium binary type. */
|
||||
QString typeMediumBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a long binary type. */
|
||||
QString typeLongBinary(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for a uuid type. */
|
||||
QString typeUuid(const ColumnDefinition &column) const;
|
||||
/*! Create the column definition for an IP address type. */
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace Constants
|
||||
SHAREDLIB_EXPORT extern const QString integer_;
|
||||
SHAREDLIB_EXPORT extern const QString varchar_;
|
||||
SHAREDLIB_EXPORT extern const QString float_;
|
||||
SHAREDLIB_EXPORT extern const QString blob_;
|
||||
SHAREDLIB_EXPORT extern const QString bytea_;
|
||||
|
||||
// Common strings
|
||||
SHAREDLIB_EXPORT extern const QString TRIM_QUOTES;
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace Constants
|
||||
inline const QString integer_ = QStringLiteral("integer");
|
||||
inline const QString varchar_ = QStringLiteral("varchar");
|
||||
inline const QString float_ = QStringLiteral("float");
|
||||
inline const QString blob_ = QStringLiteral("blob");
|
||||
inline const QString bytea_ = QStringLiteral("bytea");
|
||||
|
||||
// Common strings
|
||||
inline const QString TRIM_QUOTES = QStringLiteral("'\"");
|
||||
|
||||
@@ -51,7 +51,10 @@ namespace Orm::SchemaNs
|
||||
Timestamp,
|
||||
TimestampTz,
|
||||
Year,
|
||||
TinyBinary,
|
||||
Binary,
|
||||
MediumBinary,
|
||||
LongBinary,
|
||||
Uuid,
|
||||
IpAddress,
|
||||
MacAddress,
|
||||
|
||||
@@ -422,11 +422,26 @@ ColumnDefinitionReference<> Blueprint::year(const QString &column)
|
||||
return addColumn(ColumnType::Year, column);
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<> Blueprint::tinyBinary(const QString &column)
|
||||
{
|
||||
return addColumn(ColumnType::TinyBinary, column);
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<> Blueprint::binary(const QString &column)
|
||||
{
|
||||
return addColumn(ColumnType::Binary, column);
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<> Blueprint::mediumBinary(const QString &column)
|
||||
{
|
||||
return addColumn(ColumnType::MediumBinary, column);
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<> Blueprint::longBinary(const QString &column)
|
||||
{
|
||||
return addColumn(ColumnType::LongBinary, column);
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<> Blueprint::uuid(const QString &column)
|
||||
{
|
||||
return addColumn(ColumnType::Uuid, column);
|
||||
|
||||
@@ -556,6 +556,15 @@ QString MySqlSchemaGrammar::getType(ColumnDefinition &column) const
|
||||
case ColumnType::Binary:
|
||||
return typeBinary(column);
|
||||
|
||||
case ColumnType::TinyBinary:
|
||||
return typeTinyBinary(column);
|
||||
|
||||
case ColumnType::MediumBinary:
|
||||
return typeMediumBinary(column);
|
||||
|
||||
case ColumnType::LongBinary:
|
||||
return typeLongBinary(column);
|
||||
|
||||
case ColumnType::Uuid:
|
||||
return typeUuid(column);
|
||||
|
||||
@@ -776,9 +785,24 @@ QString MySqlSchemaGrammar::typeYear(const ColumnDefinition &/*unused*/) const /
|
||||
return QStringLiteral("year");
|
||||
}
|
||||
|
||||
QString MySqlSchemaGrammar::typeTinyBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("tinyblob");
|
||||
}
|
||||
|
||||
QString MySqlSchemaGrammar::typeBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("blob");
|
||||
return blob_;
|
||||
}
|
||||
|
||||
QString MySqlSchemaGrammar::typeMediumBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("mediumblob");
|
||||
}
|
||||
|
||||
QString MySqlSchemaGrammar::typeLongBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("longblob");
|
||||
}
|
||||
|
||||
QString MySqlSchemaGrammar::typeUuid(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
|
||||
@@ -565,6 +565,15 @@ QString PostgresSchemaGrammar::getType(ColumnDefinition &column) const
|
||||
case ColumnType::Binary:
|
||||
return typeBinary(column);
|
||||
|
||||
case ColumnType::TinyBinary:
|
||||
return typeTinyBinary(column);
|
||||
|
||||
case ColumnType::MediumBinary:
|
||||
return typeMediumBinary(column);
|
||||
|
||||
case ColumnType::LongBinary:
|
||||
return typeLongBinary(column);
|
||||
|
||||
case ColumnType::Uuid:
|
||||
return typeUuid(column);
|
||||
|
||||
@@ -801,9 +810,24 @@ QString PostgresSchemaGrammar::typeYear(const ColumnDefinition &column) const
|
||||
return typeInteger(column);
|
||||
}
|
||||
|
||||
QString PostgresSchemaGrammar::typeTinyBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return bytea_;
|
||||
}
|
||||
|
||||
QString PostgresSchemaGrammar::typeBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("bytea");
|
||||
return bytea_;
|
||||
}
|
||||
|
||||
QString PostgresSchemaGrammar::typeMediumBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return bytea_;
|
||||
}
|
||||
|
||||
QString PostgresSchemaGrammar::typeLongBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return bytea_;
|
||||
}
|
||||
|
||||
QString PostgresSchemaGrammar::typeUuid(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
|
||||
@@ -498,6 +498,15 @@ QString SQLiteSchemaGrammar::getType(ColumnDefinition &column) const
|
||||
case ColumnType::Binary:
|
||||
return typeBinary(column);
|
||||
|
||||
case ColumnType::TinyBinary:
|
||||
return typeTinyBinary(column);
|
||||
|
||||
case ColumnType::MediumBinary:
|
||||
return typeMediumBinary(column);
|
||||
|
||||
case ColumnType::LongBinary:
|
||||
return typeLongBinary(column);
|
||||
|
||||
case ColumnType::Uuid:
|
||||
return typeUuid(column);
|
||||
|
||||
@@ -687,9 +696,24 @@ QString SQLiteSchemaGrammar::typeYear(const ColumnDefinition &column) const
|
||||
return typeInteger(column);
|
||||
}
|
||||
|
||||
QString SQLiteSchemaGrammar::typeTinyBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return blob_;
|
||||
}
|
||||
|
||||
QString SQLiteSchemaGrammar::typeBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return QStringLiteral("blob");
|
||||
return blob_;
|
||||
}
|
||||
|
||||
QString SQLiteSchemaGrammar::typeMediumBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return blob_;
|
||||
}
|
||||
|
||||
QString SQLiteSchemaGrammar::typeLongBinary(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return blob_;
|
||||
}
|
||||
|
||||
QString SQLiteSchemaGrammar::typeUuid(const ColumnDefinition &/*unused*/) const // NOLINT(readability-convert-member-functions-to-static)
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace Orm::SchemaNs::Constants
|
||||
const QString integer_ = QStringLiteral("integer");
|
||||
const QString varchar_ = QStringLiteral("varchar");
|
||||
const QString float_ = QStringLiteral("float");
|
||||
const QString blob_ = QStringLiteral("blob");
|
||||
const QString bytea_ = QStringLiteral("bytea");
|
||||
|
||||
// Common strings
|
||||
const QString TRIM_QUOTES = QStringLiteral("'\"");
|
||||
|
||||
@@ -2802,6 +2802,8 @@ R"({
|
||||
"id": 3,
|
||||
"int": null,
|
||||
"int_u": null,
|
||||
"medium_binary": null,
|
||||
"medium_text": null,
|
||||
"smallint": null,
|
||||
"smallint_u": null,
|
||||
"string": null,
|
||||
|
||||
Reference in New Issue
Block a user