How to use the knex/src/query/string.escape function in knex

To help you get started, we’ve selected a few knex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rexxars / sql-to-graphql / backends / sqlite.js View on Github external
getTableStructure: function(tableName, cb) {
            var dbName = opts.database || 'main';
            var rawSql = 'pragma '
                         + knexString.escape(dbName)
                         + '.table_info('
                         + knexString.escape(tableName)
                         + ');';
            sqlite
                .raw(rawSql)
                .catch(cb)
                .then(function(info) {
                    var structure = info.map(function(col) {
                        var parensAndContents = /\(.+\)/;
                        var sanitizedType = col.type
                                               .toLowerCase()
                                               .replace(parensAndContents, '');
                        return {
                            columnName: col.name,
                            isNullable: col.notnull !== 1,
                            columnKey: col.pk === 1 ? 'PRI' : null,
                            dataType: sanitizedType
                        };
github rexxars / sql-to-graphql / backends / sqlite.js View on Github external
getTableStructure: function(tableName, cb) {
            var dbName = opts.database || 'main';
            var rawSql = 'pragma '
                         + knexString.escape(dbName)
                         + '.table_info('
                         + knexString.escape(tableName)
                         + ');';
            sqlite
                .raw(rawSql)
                .catch(cb)
                .then(function(info) {
                    var structure = info.map(function(col) {
                        var parensAndContents = /\(.+\)/;
                        var sanitizedType = col.type
                                               .toLowerCase()
                                               .replace(parensAndContents, '');
                        return {
                            columnName: col.name,
                            isNullable: col.notnull !== 1,
                            columnKey: col.pk === 1 ? 'PRI' : null,