Skip to content

Releases: wsporto/typesql

v0.16.0

28 Jan 00:31
Compare
Choose a tag to compare

Added

Postgres

Support for bulk insert using the COPY FROM statement

This new feature allows you to efficiently insert large datasets into the database with the COPY FROM statement.

Example usage:

  1. Write the SQL (bulk-insert-posts.sql)
COPY posts (
    title,
    body,
    user_id
)
FROM STDIN WITH CSV;
  1. You can use the generated bulkInsertPosts function to easily perform bulk inserts:
import pg from "pg";
const { Pool } = pg;
import { bulkInsertPosts } from "./sql";

const pool = new Pool({
    connectionString: 'postgres://postgres:[email protected]:5432/postgres'
});
const posts = //... // Array of post data

const client = await pool.connect();
await bulkInsertPosts(client, posts);

client.release();
await pool.end();

Full Changelog: v0.15.3...v0.16.0

v0.15.3

06 Jan 22:21
Compare
Choose a tag to compare

New Features

Dynamic Query Support for PostgreSQL

TypeSQL now supports Dynamic Queries for PostgreSQL. By adding the @dynamicQuery annotation to your SQL, TypeSQL generates a function with parameters to dynamically construct queries. The final SQL will include only the necessary JOINS, CTEs, and SELECT columns based on the provided parameters.

Example Usage:

  1. SQL Query with @dynamicQuery annotation:
-- @dynamicQuery
SELECT *
FROM Products
  1. You can now dynamically select columns and apply filters in a type-safe manner using the generated function.
const products = await selectProducts(conn, {
  select: {
    ProductID: true,
    ProductName: true,
    UnitPrice: true,
  },
  where: [["ProductName", "LIKE", productNameLike]],
});

Full Changelog: v0.15.2...v0.15.3

v0.15.2

31 Dec 00:26
Compare
Choose a tag to compare

New Features

Postgres

Nested Query Result Support

With this release, TypeSQL now supports Nested Query Result for PostgreSQL.

If you want to generate a nested query result, you must annotate the query with @nested in a SQL comment:

-- @nested
SELECT
  *
FROM users
INNER JOIN posts ON posts.user_id = users.id

Once the query is annotated, TypeSQL will automatically generate the appropriate nested type:

const result = await selectUserPostsNested(conn);

// Result type:
const result: {
  id: number;
  name: string;
  posts: {
    id: number;
    title: string;
    body: string;
  }[];
}[];

Full Changelog: v0.15.1...v0.15.2

v0.15.1

22 Dec 02:31
Compare
Choose a tag to compare

New Features

Postgres

* Automatic CRUD generation

With this release, TypeSQL now supports automatic CRUD generation for PostgreSQL databases.

By including the includeCrudTables option in your typesql.json configuration file, TypeSQL will automatically generate functions for CRUD (Create, Read, Update, Delete) operations for the specified tables.

Example:

{
    "databaseUri": "postgres://postgres:[email protected]:5432/postgres",
    "sqlDir": "./src/sql",
    "client": "pg",
    "includeCrudTables": ["books"]
}

In this example, TypeSQL will generate the following functions for the books table:

  • insertIntoBooks(...)
  • selectFromBooks(...)
  • updateBooks(...)
  • deleteFromBooks(...)

These functions allow you to easily interact with the books table and perform common CRUD operations without manually writing SQL queries.

Full Changelog: v0.15.0...v0.15.1

v0.15.0

18 Dec 01:34
770502a
Compare
Choose a tag to compare

New Features:

- Experimental Support for PostgreSQL:

This release adds experimental support for PostgreSQL (pg driver).

Please note that this feature is still in the experimental phase and may have limited functionality or contain bugs. We encourage users to test it and provide feedback.

How to configure:

To configure TypeSQL for PostgreSQL, use a configuration file (typesql.json) as shown in the example below:

{
    "databaseUri": "postgres://postgres:[email protected]:5432/postgres",
    "sqlDir": "./src/sql",
    "client": "pg"
}

Full Changelog: v0.14.3...v0.15.0

v0.14.3

14 Dec 01:25
Compare
Choose a tag to compare

What's Changed

SQLite:

  • fix multiple rows result for table with composite key [#37]

Full Changelog: v0.14.2...v0.14.3

v0.14.2

28 Nov 17:41
Compare
Choose a tag to compare

What's Changed

SQLite:

  • Added support for char function

Full Changelog: v0.14.1...v0.14.2

v0.14.1

27 Nov 00:56
Compare
Choose a tag to compare

What's Changed

SQLite:

  • Added support for pipe operator (||)
  • Added support for trim, ltrim, rtrim and replace functions
  • Allow usage of column alias in WHERE expression

Full Changelog: v0.14.0...v0.14.1

v0.14.0

26 Nov 19:45
Compare
Choose a tag to compare

New Features:

  • Added initial support for JSON functions.

Supported JSON Functions:

Scalar functions:

  • json
  • jsonb
  • json_array
  • jsonb_array
  • json_array_length
  • json_error_position
  • json_extract
  • jsonb_extract

Table-valued functions:

  • json_each
  • json_tree

Full Changelog: v0.13.1...v0.14.0

v0.13.1

25 Nov 00:44
Compare
Choose a tag to compare

What's Changed

  • handle SQLite generated columns

Full Changelog: v0.13.0...v0.13.1