Developer
News and Updates
Get Support
Sign in
Get Support
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Key-Value Store
Custom Entity Store
SQL
Object Store (Preview)
Last updated Jul 14, 2026

Forge SQL data types

Forge SQL is built on TiDB and supports MySQL-compatible data types. This page describes the supported types, explains how Forge SQL returns query results, and covers known limitations.

Forge SQL encodes and decodes query results as JSON. All returned values are JSON-normalised, so you must convert them to the correct type in your app code.

Supported data types

Forge SQL supports all MySQL-compatible data types that TiDB supports. The following table shows the most commonly used types, the format they're returned in, and how to handle them in your app.

Numeric types

TypeDescriptionReturned asHandling notes
INT / INTEGER32-bit signed integerNumberNo conversion needed for most values
BIGINT64-bit signed integerStringConvert with BigInt() or a numeric library — see Handling BIGINT values
TINYINT8-bit signed integerNumberNo conversion needed
SMALLINT16-bit signed integerNumberNo conversion needed
MEDIUMINT24-bit signed integerNumberNo conversion needed
DECIMAL / NUMERICExact fixed-point numberStringParse with a decimal library (such as decimal.js or big.js) to preserve precision — parseFloat() converts to floating-point and does not preserve exact decimal values
FLOATSingle-precision floating-pointNumberSubject to standard floating-point precision limits
DOUBLEDouble-precision floating-pointNumberSubject to standard floating-point precision limits
BITBit-field valueNumber

String types

TypeDescriptionReturned asHandling notes
CHARFixed-length stringStringNo conversion needed
VARCHARVariable-length stringStringNo conversion needed
TEXTVariable-length text (up to 65,535 bytes)StringHidden in the schema viewer — see Hidden fields
MEDIUMTEXTVariable-length text (up to 16 MB)StringHidden in the schema viewer — see Hidden fields
LONGTEXTVariable-length text (up to 4 GB)StringHidden in the schema viewer — see Hidden fields
TINYTEXTVariable-length text (up to 255 bytes)String

Binary types

Binary types are hidden in the Forge SQL schema viewer. You can store and query these types, but the Table data tab in the Developer Console won't display them. See Hidden fields.

TypeDescriptionReturned asHandling notes
BINARYFixed-length binary dataStringHidden in schema viewer
VARBINARYVariable-length binary dataStringHidden in schema viewer
BLOBBinary large object (up to 65,535 bytes)StringHidden in schema viewer
MEDIUMBLOBBinary large object (up to 16 MB)StringHidden in schema viewer
LONGBLOBBinary large object (up to 4 GB)StringHidden in schema viewer

Date and time types

Forge SQL supports the following date and time types. Each type has a specific input and return format — ensure your values match the format shown below.

TypeFormatExampleReturned as
DATEYYYY-MM-DD2024-09-19String
TIMEHH:MM:SS[.fraction]06:40:34String
DATETIMEYYYY-MM-DD HH:MM:SS[.fraction]2024-09-19 06:40:34.999999String
TIMESTAMPYYYY-MM-DD HH:MM:SS[.fraction]2024-09-19 06:40:34.999999String
YEARYYYY2024Number

Because Forge SQL returns date and time values as strings, you must parse them in your app code. We recommend using a date library such as moment or the native Date object:

1
2
import sql from '@forge/sql';
import moment from 'moment';

interface LoginDetails {
  id: number;
  CreatedAt: string;
  LastLoginTimestamp: string;
}

try {
  const result = await sql
    .prepare<LoginDetails>('SELECT * FROM LoginDetails WHERE id = ?')
    .bindParams(1)
    .execute();

  if (result.rows.length === 0) {
    throw new Error('No login details found');
  }

  const row = result.rows[0];
  const createdAt = moment(row.CreatedAt, 'YYYY-MM-DD').toDate();
  const lastLogin = new Date(row.LastLoginTimestamp);
} catch (error) {
  console.error('Error fetching login details:', error);
  throw error;
}

Boolean type

TypeDescriptionReturned asHandling notes
BOOLEAN / BOOLAlias for TINYINT(1)Number (0 or 1)Convert to boolean with Boolean(value) or value === 1

JSON type

JSON data types may not be supported in future versions of Forge SQL. We recommend storing JSON as a TEXT or VARCHAR column and serialising/deserialising in your app code instead.

TypeDescriptionReturned as
JSONJSON documentString

If you store JSON directly in a JSON column, the value is returned as a string. Deserialise it with JSON.parse():

1
2
import sql from '@forge/sql';

interface Product {
  id: number;
  metadata: string; // raw JSON string
}

const result = await sql
  .prepare<Product>('SELECT id, metadata FROM products WHERE id = ?')
  .bindParams(42)
  .execute();

if (result.rows.length === 0) {
  throw new Error('Product not found');
}

let metadata;
try {
  metadata = JSON.parse(result.rows[0].metadata);
  // Use metadata
} catch (error) {
  console.error('Failed to parse metadata JSON:', error);
  throw new Error('Invalid metadata format');
}

Handling BIGINT values

JavaScript's number type is a 64-bit floating-point value (IEEE 754). It can only safely represent integers up to 2^53 - 1 (Number.MAX_SAFE_INTEGER). BIGINT columns can hold values larger than this, so Forge SQL returns BIGINT values as strings to preserve precision.

To work with large integers, use JavaScript's native BigInt type:

1
2
import sql from '@forge/sql';

interface Counter {
  id: number;
  count: string; // BIGINT returned as string
}

const result = await sql
  .prepare<Counter>('SELECT id, count FROM event_counters WHERE id = ?')
  .bindParams(1)
  .execute();

if (result.rows.length === 0) {
  throw new Error('Counter not found');
}

const count = BigInt(result.rows[0].count);
const incremented = count + 1n;

await sql
  .prepare('UPDATE event_counters SET count = ? WHERE id = ?')
  .bindParams(incremented.toString(), 1)
  .execute();

When binding a BIGINT parameter, pass the value as a string (for example, bigIntValue.toString()). Passing a JavaScript number may silently lose precision for values outside the safe integer range.

Type conversion summary

Because all Forge SQL query results are JSON-normalised, some database types are not returned in their native form. The following table summarises what to expect:

Database typeReturned as in JavaScriptConversion needed?
INT, SMALLINT, TINYINT, MEDIUMINTnumberNo
BIGINTstringYes — use BigInt()
DECIMAL, NUMERICstringYes — use a decimal library (such as decimal.js or big.js)
FLOAT, DOUBLEnumberNo (subject to floating-point precision)
VARCHAR, CHAR, TEXTstringNo
DATE, TIME, DATETIME, TIMESTAMPstringYes — parse with Date or a date library
BOOLEANnumber (0 or 1)Yes — convert with Boolean()
JSONstringYes — parse with JSON.parse()
BLOB, BINARY, VARBINARYstringDepends on use case

Hidden fields

The Table data tab within the Schema viewer won't display fields with the following database data types:

  • BLOB
  • MEDIUMBLOB
  • LONGBLOB
  • BINARY
  • VARBINARY
  • CLOB
  • TEXT
  • IMAGE
  • XML
  • JSON

These field are hidden to prevent the display of possibly large data payloads. These fields won't be included in the records provided through the Download button either.

The following types are hidden in the schema viewer:

  • BLOB, MEDIUMBLOB, LONGBLOB
  • BINARY, VARBINARY
  • CLOB
  • TEXT, IMAGE, XML, JSON

These types are hidden to prevent displaying large data payloads. They are also excluded from data downloaded through the Download button in the Developer Console.

CLOB, IMAGE, and XML are not MySQL-compatible data types and are not supported by Forge SQL. They appear in this list because the schema viewer hides them if somehow present, but you should not use these types in your schemas.

Rate this page: