Skip to content

Commit 77aa0f4

Browse files
committed
Support for max length
Signed-off-by: worksofliam <[email protected]>
1 parent 5f66554 commit 77aa0f4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-db2i",
33
"displayName": "Db2 for IBM i",
44
"description": "Db2 for IBM i tools in VS Code",
5-
"version": "1.6.3-scott2",
5+
"version": "1.6.3-scott3",
66
"engines": {
77
"vscode": "^1.95.0"
88
},

src/views/results/html.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface BasicColumn {
4444
name: string;
4545
useInWhere: boolean
4646
jsType: "number"|"asString";
47+
maxInputLength?: number;
4748
}
4849

4950
export function generateScroller(basicSelect: string, isCL: boolean, withCancel?: boolean, updatable?: UpdatableInfo): string {
@@ -156,9 +157,13 @@ export function generateScroller(basicSelect: string, isCL: boolean, withCancel?
156157
editableNode.removeEventListener('keydown', keydownEvent);
157158
158159
editableNode.contentEditable = false;
159-
const newValue = editableNode.innerText;
160+
let newValue = editableNode.innerText;
160161
161162
if (newValue === chosenValue) return;
163+
if (chosenColumnDetail.maxInputLength && newValue.length > chosenColumnDetail.maxInputLength) {
164+
newValue = newValue.substring(0, chosenColumnDetail.maxInputLength);
165+
editableNode.innerText = newValue;
166+
}
162167
163168
const useRrn = updateKeyColumns.length === 1 && updateKeyColumns.some(col => col.name === 'RRN');
164169

src/views/results/resultSetPanelProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
184184
if (tableInfo.length > 0) {
185185
let currentColumns: html.BasicColumn[]|undefined;
186186

187-
currentColumns = tableInfo.map((column) => ({name: column.COLUMN_NAME, jsType: column.NUMERIC_PRECISION ? `number` : `asString`, useInWhere: column.IS_IDENTITY === `YES` || column.CONSTRAINT_NAME !== null}));
187+
currentColumns = tableInfo.map((column) => ({
188+
name: column.COLUMN_NAME,
189+
jsType: column.NUMERIC_PRECISION ? `number` : `asString`,
190+
useInWhere: column.IS_IDENTITY === `YES` || column.CONSTRAINT_NAME !== null,
191+
maxInputLength: column.CHARACTER_MAXIMUM_LENGTH
192+
}));
188193

189194
if (!currentColumns.some(c => c.useInWhere)) {
190195
// We need to override the input statement if they want to do updatable

0 commit comments

Comments
 (0)