Skip to content

Commit a49055e

Browse files
authored
Merge pull request #409 from machbase/wip-view
add view type
1 parent 2311f78 commit a49055e

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

jsh/lib/machcli/machcli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const TableType = {
178178
Lookup: 4,
179179
KeyValue: 5,
180180
Tag: 6,
181+
View: 7,
181182
};
182183

183184
function stringTableType(typ) {
@@ -194,6 +195,8 @@ function stringTableType(typ) {
194195
return "KeyValue";
195196
case TableType.Tag:
196197
return "Tag";
198+
case TableType.View:
199+
return "View";
197200
default:
198201
return `UndefinedTable-${typ}`;
199202
}

jsh/lib/machcli/machcli_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func TestDatabase(t *testing.T) {
4646
result = conn.exec("CREATE TAG TABLE IF NOT EXISTS TAG (NAME VARCHAR(100) primary key, TIME DATETIME basetime, VALUE DOUBLE)");
4747
console.println("Created Table Message:", result.message);
4848
49+
result = conn.exec("CREATE VIEW TAGVIEW as select * from TAG where name='jsh'");
50+
console.println("Created View Message:", result.message);
51+
4952
result = conn.exec("INSERT INTO TAG values(?, ?, ?)", 'jsh', tick, 123);
5053
console.println("Inserted rows:", result.rowsAffected, "Message:", result.message);
5154
} catch(err) {
@@ -57,9 +60,31 @@ func TestDatabase(t *testing.T) {
5760
`,
5861
Output: []string{
5962
"Created Table Message: ",
63+
"Created View Message: ",
6064
"Inserted rows: 1 Message: ",
6165
},
6266
},
67+
{
68+
Name: "mach_table_types",
69+
Script: `
70+
const {Client, stringTableType} = require('machcli');
71+
const conf = require("process").env.get("conf");
72+
db = new Client(conf);
73+
conn = db.connect();
74+
rows = conn.query("SELECT NAME, TYPE from M$SYS_TABLES ORDER BY NAME");
75+
for (const row of rows) {
76+
if (row.NAME.startsWith("_")) continue;
77+
console.println("TABLE:", row.NAME, "TYPE:", stringTableType(row.TYPE));
78+
}
79+
rows.close();
80+
conn.close();
81+
db.close();
82+
`,
83+
Output: []string{
84+
"TABLE: TAG TYPE: Tag",
85+
"TABLE: TAGVIEW TYPE: View",
86+
},
87+
},
6388
{
6489
Name: "mach_append",
6590
Script: `

0 commit comments

Comments
 (0)