happy-sql 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2026.08.15, v1.5.3
2
+
3
+ feature:
4
+ - e4a8ea9 happy-sql: identity column support
5
+
1
6
  2026.08.15, v1.5.2
2
7
 
3
8
  feature:
@@ -15,6 +15,18 @@ const convertConstraint = (constraint) => {
15
15
  if (constraint.type === 'constraint_primary_key')
16
16
  return callExpression(identifier('primaryKey'), []);
17
17
 
18
+ if (constraint.type === 'constraint_generated') {
19
+ const kws = [];
20
+
21
+ for (const kw of constraint.generatedKw)
22
+ kws.push(kw.name);
23
+
24
+ if (kws.includes('DEFAULT'))
25
+ return callExpression(identifier('identityByDefault'), []);
26
+
27
+ return callExpression(identifier('identity'), []);
28
+ }
29
+
18
30
  return callExpression(identifier('autoIncrement'), []);
19
31
  };
20
32
 
@@ -0,0 +1,5 @@
1
+ [
2
+ createTable(t, [
3
+ column(id, BIGINT, identity(), primaryKey()),
4
+ ]),
5
+ ];
@@ -0,0 +1 @@
1
+ CREATE TABLE t (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY)
@@ -0,0 +1,5 @@
1
+ [
2
+ createTable(t, [
3
+ column(id, BIGINT, identityByDefault(), primaryKey()),
4
+ ]),
5
+ ];
@@ -0,0 +1 @@
1
+ CREATE TABLE t (id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY)
@@ -78,6 +78,7 @@ const convertBinary = (node) => {
78
78
 
79
79
  if (op === 'IN') {
80
80
  const items = node.right.expr.items.map(convertOperand);
81
+
81
82
  return callExpression(identifier('inList'), [
82
83
  convertOperand(node.left),
83
84
  ...items,
@@ -55,6 +55,7 @@ const convertBinary = (node) => {
55
55
 
56
56
  if (op === 'IN') {
57
57
  const items = node.right.expr.items.map(convertOperand);
58
+
58
59
  return callExpression(identifier('inList'), [
59
60
  convertOperand(node.left),
60
61
  ...items,
@@ -25,6 +25,10 @@ import {lastval} from './lastval/lastval.js';
25
25
  import {like} from './like/like.js';
26
26
  import {isNull, isNotNull} from './is-null/is-null.js';
27
27
  import {inList} from './in-list/in-list.js';
28
+ import {
29
+ identity,
30
+ identityByDefault,
31
+ } from './identity/identity.js';
28
32
 
29
33
  export const clauses = {
30
34
  join,
@@ -55,4 +59,6 @@ export const clauses = {
55
59
  isNull,
56
60
  isNotNull,
57
61
  inList,
62
+ identity,
63
+ identityByDefault,
58
64
  };
@@ -0,0 +1 @@
1
+ CREATE TABLE t (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY)
@@ -0,0 +1,5 @@
1
+ [
2
+ createTable(t, [
3
+ column(id, BIGINT, identity(), primaryKey()),
4
+ ]),
5
+ ];
@@ -0,0 +1 @@
1
+ CREATE TABLE t (id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY)
@@ -0,0 +1,5 @@
1
+ [
2
+ createTable(t, [
3
+ column(id, BIGINT, identityByDefault(), primaryKey()),
4
+ ]),
5
+ ];
@@ -0,0 +1,3 @@
1
+ export const identity = (path, {write}) => write('GENERATED ALWAYS AS IDENTITY');
2
+
3
+ export const identityByDefault = (path, {write}) => write('GENERATED BY DEFAULT AS IDENTITY');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-sql",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "description": "sql to js ast parser and printer",
6
6
  "exports": {