@rudsys/n8n-nodes-sqlite3 0.1.4 → 0.1.6
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.
|
@@ -88,19 +88,84 @@ class SqliteSsh {
|
|
|
88
88
|
required: true,
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
|
-
displayName: 'Columns
|
|
92
|
-
name: '
|
|
93
|
-
type: '
|
|
91
|
+
displayName: 'Columns',
|
|
92
|
+
name: 'columnsUi',
|
|
93
|
+
type: 'fixedCollection',
|
|
94
|
+
typeOptions: {
|
|
95
|
+
multipleValues: true,
|
|
96
|
+
},
|
|
94
97
|
displayOptions: {
|
|
95
98
|
show: {
|
|
96
99
|
operation: ['manageTables'],
|
|
97
100
|
tableAction: ['create'],
|
|
98
101
|
},
|
|
99
102
|
},
|
|
100
|
-
default:
|
|
101
|
-
placeholder: '
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
default: {},
|
|
104
|
+
placeholder: 'Add Column',
|
|
105
|
+
options: [
|
|
106
|
+
{
|
|
107
|
+
name: 'column',
|
|
108
|
+
displayName: 'Column',
|
|
109
|
+
values: [
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Name',
|
|
112
|
+
name: 'name',
|
|
113
|
+
type: 'string',
|
|
114
|
+
default: '',
|
|
115
|
+
required: true,
|
|
116
|
+
description: 'Name of the column',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
displayName: 'Type',
|
|
120
|
+
name: 'type',
|
|
121
|
+
type: 'options',
|
|
122
|
+
options: [
|
|
123
|
+
{ name: 'INTEGER', value: 'INTEGER' },
|
|
124
|
+
{ name: 'TEXT', value: 'TEXT' },
|
|
125
|
+
{ name: 'REAL', value: 'REAL' },
|
|
126
|
+
{ name: 'BLOB', value: 'BLOB' },
|
|
127
|
+
{ name: 'NUMERIC', value: 'NUMERIC' },
|
|
128
|
+
],
|
|
129
|
+
default: 'TEXT',
|
|
130
|
+
description: 'Data type of the column',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Primary Key',
|
|
134
|
+
name: 'primaryKey',
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
default: false,
|
|
137
|
+
description: 'Whether this column is a primary key',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
displayName: 'Auto Increment',
|
|
141
|
+
name: 'autoIncrement',
|
|
142
|
+
type: 'boolean',
|
|
143
|
+
default: false,
|
|
144
|
+
displayOptions: {
|
|
145
|
+
show: {
|
|
146
|
+
primaryKey: [true],
|
|
147
|
+
type: ['INTEGER'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
description: 'Whether this column should auto increment (only for INTEGER PRIMARY KEY)',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
displayName: 'Not Null',
|
|
154
|
+
name: 'notNull',
|
|
155
|
+
type: 'boolean',
|
|
156
|
+
default: false,
|
|
157
|
+
description: 'Whether this column cannot be null',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
displayName: 'Unique',
|
|
161
|
+
name: 'unique',
|
|
162
|
+
type: 'boolean',
|
|
163
|
+
default: false,
|
|
164
|
+
description: 'Whether values in this column must be unique',
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
],
|
|
104
169
|
},
|
|
105
170
|
// ------------------ Column Operations ------------------
|
|
106
171
|
{
|
|
@@ -396,8 +461,25 @@ class SqliteSsh {
|
|
|
396
461
|
// For rename: table param is OLD name, newTableName is NEW name
|
|
397
462
|
// For drop: table param is table to drop
|
|
398
463
|
if (action === 'create') {
|
|
399
|
-
const
|
|
400
|
-
|
|
464
|
+
const columnsUi = this.getNodeParameter('columnsUi', i);
|
|
465
|
+
const columns = (columnsUi === null || columnsUi === void 0 ? void 0 : columnsUi.column) || [];
|
|
466
|
+
if (!columns.length) {
|
|
467
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one column is required to create a table', { itemIndex: i });
|
|
468
|
+
}
|
|
469
|
+
const columnDefs = columns.map((col) => {
|
|
470
|
+
let def = `${escapeIdentifier(col.name)} ${col.type}`;
|
|
471
|
+
if (col.primaryKey) {
|
|
472
|
+
def += ' PRIMARY KEY';
|
|
473
|
+
if (col.autoIncrement && col.type === 'INTEGER')
|
|
474
|
+
def += ' AUTOINCREMENT';
|
|
475
|
+
}
|
|
476
|
+
if (col.notNull)
|
|
477
|
+
def += ' NOT NULL';
|
|
478
|
+
if (col.unique)
|
|
479
|
+
def += ' UNIQUE';
|
|
480
|
+
return def;
|
|
481
|
+
});
|
|
482
|
+
sql = `CREATE TABLE ${table} (${columnDefs.join(', ')});`;
|
|
401
483
|
}
|
|
402
484
|
else if (action === 'rename') {
|
|
403
485
|
const newName = escapeIdentifier(this.getNodeParameter('newTableName', i));
|
|
@@ -417,7 +499,11 @@ class SqliteSsh {
|
|
|
417
499
|
else {
|
|
418
500
|
const colName = escapeIdentifier(this.getNodeParameter('columnName', i));
|
|
419
501
|
if (action === 'add') {
|
|
420
|
-
|
|
502
|
+
let colDef = this.getNodeParameter('columnDefinition', i);
|
|
503
|
+
colDef = colDef.trim();
|
|
504
|
+
if (colDef.startsWith('(') && colDef.endsWith(')')) {
|
|
505
|
+
colDef = colDef.slice(1, -1);
|
|
506
|
+
}
|
|
421
507
|
sql = `ALTER TABLE ${table} ADD COLUMN ${colName} ${colDef};`;
|
|
422
508
|
}
|
|
423
509
|
else if (action === 'rename') {
|