Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable cells #300

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-db2i",
"displayName": "Db2 for IBM i",
"description": "Db2 for IBM i tools in VS Code",
"version": "1.6.3",
"version": "1.6.3-scott12",
"engines": {
"vscode": "^1.95.0"
},
Expand Down
41 changes: 37 additions & 4 deletions src/database/table.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

import vscode from "vscode"
import { JobManager } from "../config";
import { getInstance } from "../base";
import Statement from "./statement";

export default class Table {
/**
Expand Down Expand Up @@ -32,11 +30,46 @@ export default class Table {
` column.table_schema = key.table_schema and`,
` column.table_name = key.table_name and`,
` column.column_name = key.column_name`,
`WHERE column.TABLE_SCHEMA = '${schema}' AND column.TABLE_NAME = '${name}'`,
`WHERE column.TABLE_SCHEMA = ? AND column.TABLE_NAME = ?`,
`ORDER BY column.ORDINAL_POSITION`,
].join(` `);

return JobManager.runSQL(sql);
return JobManager.runSQL(sql, {parameters: [schema, name]});
}

/**
* This is to be used instead of getItems when the table is in session/QTEMP
*/
static async getSessionItems(name: string): Promise<TableColumn[]> {
const sql = [
`SELECT `,
` column.TABLE_SCHEMA,`,
` column.TABLE_NAME,`,
` column.COLUMN_NAME,`,
` '' as CONSTRAINT_NAME,`,
` column.DATA_TYPE, `,
` column.CHARACTER_MAXIMUM_LENGTH,`,
` column.NUMERIC_SCALE, `,
` column.NUMERIC_PRECISION,`,
` column.IS_NULLABLE, `,
` column.HAS_DEFAULT, `,
` column.COLUMN_DEFAULT, `,
` column.COLUMN_TEXT, `,
` column.IS_IDENTITY`,
`FROM QSYS2.SYSCOLUMNS2_SESSION as column`,
`WHERE column.TABLE_NAME = ?`,
`ORDER BY column.ORDINAL_POSITION`,
].join(` `);

return JobManager.runSQL(sql, {parameters: [name]});
}

static async isPartitioned(schema: string, name: string): Promise<boolean> {
const sql = `select table_name, partitioned_table from qsys2.sysfiles where table_schema = ? and table_name = ? and partitioned_table is not null and partitioned_table = 'YES'`;
const parameters = [schema, name];

const result = await JobManager.runSQL(sql, {parameters});
return result.length > 0;
}

static async clearFile(library: string, objectName: string): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/language/sql/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Statement {
first = this.tokens[2];
}

if (tokenIs(first, `word`) && tokenIs(this.tokens[1], `colon`)) {
if (first.value !== undefined && tokenIs(this.tokens[1], `colon`)) {
// Possible label?
this.label = first.value;
first = this.tokens[2];
Expand Down
9 changes: 6 additions & 3 deletions src/views/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function getHeader(options: {withCollapsed?: boolean} = {}): string {
border-collapse: collapse;
font-size: 0.9em;
font-family: sans-serif;
min-width: 400px;
min-width: 100%;
}

thead tr {
Expand All @@ -20,11 +20,14 @@ export function getHeader(options: {withCollapsed?: boolean} = {}): string {
top: 0; /* Don't forget this, required for the stickiness */
}

tfoot {
position: sticky;
bottom: 0;
}

tfoot tr {
background-color: var(--vscode-multiDiffEditor-headerBackground);
text-align: left;
position: sticky; /* Lock the footer row to the bottom so it's always visible as rows are scrolled */
bottom: 0; /* Don't forget this, required for the stickiness */
}

#resultset th,
Expand Down
Loading