mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
Pivot implementation and redesign (#69)
- Pivot support implementation - Rename queries into inquiries - Rename editor into workspace - Change result set format - New JSON format for inquiries - Redesign panels
This commit is contained in:
@@ -3,16 +3,18 @@ import stmts from '@/lib/database/_statements'
|
||||
|
||||
describe('_statements.js', () => {
|
||||
it('generateChunks', () => {
|
||||
const arr = ['1', '2', '3', '4', '5']
|
||||
const source = {
|
||||
id: ['1', '2', '3', '4', '5']
|
||||
}
|
||||
const size = 2
|
||||
const chunks = stmts.generateChunks(arr, size)
|
||||
const chunks = stmts.generateChunks(source, size)
|
||||
const output = []
|
||||
for (const chunk of chunks) {
|
||||
output.push(chunk)
|
||||
}
|
||||
expect(output[0]).to.eql(['1', '2'])
|
||||
expect(output[1]).to.eql(['3', '4'])
|
||||
expect(output[2]).to.eql(['5'])
|
||||
expect(output[0]).to.eql([['1'], ['2']])
|
||||
expect(output[1]).to.eql([['3'], ['4']])
|
||||
expect(output[2]).to.eql([['5']])
|
||||
})
|
||||
|
||||
it('getInsertStmt', () => {
|
||||
@@ -22,12 +24,14 @@ describe('_statements.js', () => {
|
||||
})
|
||||
|
||||
it('getCreateStatement', () => {
|
||||
const columns = ['id', 'name', 'isAdmin', 'startDate']
|
||||
const values = [
|
||||
[1, 'foo', true, new Date()],
|
||||
[2, 'bar', false, new Date()]
|
||||
]
|
||||
expect(stmts.getCreateStatement('foo', columns, values)).to.equal(
|
||||
const data = {
|
||||
id: [1, 2],
|
||||
name: ['foo', 'bar'],
|
||||
isAdmin: [true, false],
|
||||
startDate: [new Date(), new Date()]
|
||||
}
|
||||
|
||||
expect(stmts.getCreateStatement('foo', data)).to.equal(
|
||||
'CREATE table "foo"("id" REAL, "name" TEXT, "isAdmin" INTEGER, "startDate" TEXT);'
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user