1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

Virtual tables are displayed now #13

This commit is contained in:
lana-k
2020-11-11 19:45:41 +01:00
parent 9912ed24cf
commit 3f0a7597a2

View File

@@ -39,14 +39,28 @@ export default {
}, },
computed: { computed: {
ast () { ast () {
return sqliteParser(this.sql) // There is a bug is sqlite-parser
// It throws an error if tokenizer has an arguments:
// https://github.com/codeschool/sqlite-parser/issues/59
const fixedSql = this.sql
.replace(/(?<=tokenize=.+)"tokenchars=.+"/, '')
.replace(/(?<=tokenize=.+)"remove_diacritics=.+"/, '')
.replace(/(?<=tokenize=.+)"separators=.+"/, '')
.replace(/tokenize=.+(?=(,|\)))/, 'tokenize=unicode61')
return sqliteParser(fixedSql)
}, },
columns () { columns () {
const columns = [] const columns = []
this.ast.statement[0].definition.forEach(item => {
if (item.variant === 'column') { const columnDefinition = this.ast.statement[0].format === 'table'
let type = item.datatype.variant ? this.ast.statement[0].definition
if (item.datatype.args) { : this.ast.statement[0].result.args.expression // virtual table
columnDefinition.forEach(item => {
if (item.variant === 'column' && ['identifier', 'definition'].includes(item.type)) {
let type = item.datatype ? item.datatype.variant : 'N/A'
if (item.datatype && item.datatype.args) {
type = type + '(' + item.datatype.args.expression[0].value type = type + '(' + item.datatype.args.expression[0].value
if (item.datatype.args.expression.length === 2) { if (item.datatype.args.expression.length === 2) {
type = type + ', ' + item.datatype.args.expression[1].value type = type + ', ' + item.datatype.args.expression[1].value
@@ -61,6 +75,7 @@ export default {
} }
} }
</script> </script>
<style scoped> <style scoped>
.table-name, .column { .table-name, .column {
margin-top: 11px; margin-top: 11px;