@@ -14,7 +14,7 @@ import * as interfaces from './interfaces';
1414import { verifyInclusion , verifyDualProof } from './verification'
1515import { CLIENT_INIT_PREFIX , DEFAULT_DATABASE , DEFAULT_ROOTPATH } from './consts'
1616import { getSQLValue } from './common' ;
17- import Parameters , { SQLValue } from '../types/parameters'
17+ import Parameters , { SQLColumnValue , } from '../types/parameters'
1818
1919class ImmudbClient {
2020 public state : State ;
@@ -1684,7 +1684,7 @@ class ImmudbClient {
16841684 }
16851685 }
16861686
1687- async SQLQuery ( { sql, params = { } , reusesnapshot = false } : Parameters . SQLQuery ) : Promise < Array < Array < SQLValue > > | undefined > {
1687+ async SQLQuery ( { sql, params = { } , reusesnapshot = false } : Parameters . SQLQuery ) : Promise < Array < SQLColumnValue > | undefined > {
16881688 try {
16891689 const req = new schemaTypes . SQLQueryRequest ( ) ;
16901690
@@ -1704,66 +1704,62 @@ class ImmudbClient {
17041704 return new Promise ( ( resolve , reject ) => this . client . sQLQuery ( req , this . _metadata , ( err , res ) => {
17051705 if ( err ) {
17061706 console . error ( 'SQLQuery error' , err )
1707-
17081707 reject ( err )
17091708 } else {
17101709 resolve (
17111710 res
1712- . getRowsList ( )
1713- . map ( row => row
1714- . getValuesList ( )
1715- . map ( value => value . hasNull ( )
1716- ? value . getNull ( )
1717- : value . hasS ( )
1718- ? value . getS ( )
1719- : value . hasN ( )
1720- ? value . getN ( )
1721- : value . hasB ( )
1722- ? value . getB ( )
1723- : value . hasBs ( )
1724- ? value . getBs_asU8 ( )
1725- : null )
1726- ) )
1711+ . getRowsList ( )
1712+ . map ( row => {
1713+ const [ name , type , nullable , index , autoincrement , unique , ] = row . getValuesList ( ) ;
1714+ return {
1715+ name : name . getS ( ) ,
1716+ type : type ?. getS ( ) ,
1717+ nullable : nullable ?. getB ( ) ,
1718+ index : index ?. getS ( ) ,
1719+ autoincrement : autoincrement ?. getB ( ) ,
1720+ unique : unique ?. getB ( )
1721+ } ;
1722+ } )
1723+ ) ;
17271724 }
17281725 } ) )
17291726 } catch ( err ) {
17301727 console . error ( err ) ;
17311728 }
17321729 }
17331730
1734- async SQLListTables ( ) : Promise < Array < Array < SQLValue > > | undefined > {
1731+ async SQLListTables ( ) : Promise < Array < SQLColumnValue > | undefined > {
17351732 try {
17361733 const req = new empty . Empty ( )
17371734
17381735 return new Promise ( ( resolve , reject ) => this . client . listTables ( req , this . _metadata , ( err , res ) => {
17391736 if ( err ) {
17401737 console . error ( 'SQLListTables error' , err ) ;
1741-
17421738 reject ( err ) ;
17431739 } else {
1744- resolve ( res
1745- . getRowsList ( )
1746- . map ( row => row
1747- . getValuesList ( )
1748- . map ( value => value . hasNull ( )
1749- ? value . getNull ( )
1750- : value . hasS ( )
1751- ? value . getS ( )
1752- : value . hasN ( )
1753- ? value . getN ( )
1754- : value . hasB ( )
1755- ? value . getB ( )
1756- : value . hasBs ( )
1757- ? value . getBs_asU8 ( )
1758- : null ) ) )
1740+ resolve (
1741+ res
1742+ . getRowsList ( )
1743+ . map ( row => {
1744+ const [ name , type , nullable , index , autoincrement , unique , ] = row . getValuesList ( ) ;
1745+ return {
1746+ name : name . getS ( ) ,
1747+ type : type ? .getS ( ) ,
1748+ nullable : nullable ?. getB ( ) ,
1749+ index : index ?. getS ( ) ,
1750+ autoincrement : autoincrement ?. getB ( ) ,
1751+ unique : unique ? .getB ( )
1752+ } ;
1753+ } )
1754+ ) ;
17591755 }
1760- } ) )
1756+ } ) ) ;
17611757 } catch ( err ) {
17621758 console . error ( err ) ;
17631759 }
17641760 }
17651761
1766- async SQLDescribe ( tableName : string ) {
1762+ async SQLDescribe ( tableName : string ) : Promise < Array < SQLColumnValue > | undefined > {
17671763 const request = new schemaTypes . Table ( ) ;
17681764 request . setTablename ( tableName ) ;
17691765
@@ -1778,18 +1774,16 @@ class ImmudbClient {
17781774 . getRowsList ( )
17791775 . map ( row => {
17801776 const [ name , type , nullable , index , autoincrement , unique , ] = row . getValuesList ( ) ;
1781-
17821777 return {
17831778 name : name . getS ( ) ,
1784- type : type . getS ( ) ,
1785- nullable : nullable . getB ( ) ,
1786- index : index . getS ( ) ,
1787- autoincrement : autoincrement . getB ( ) ,
1788- unique : unique . getB ( )
1779+ type : type ? .getS ( ) ,
1780+ nullable : nullable ? .getB ( ) ,
1781+ index : index ? .getS ( ) ,
1782+ autoincrement : autoincrement ? .getB ( ) ,
1783+ unique : unique ? .getB ( )
17891784 } ;
1790- }
1791- )
1792- )
1785+ } )
1786+ ) ;
17931787 }
17941788 } )
17951789 } )
0 commit comments