skip to Main Content

when I open the web page via node express + mybatis-mapper,
it works on dev environment on my PC(windows + vscode).
But it not works on linux(ubuntu) server with below error message.

It seems like xml encoding error, but I can’t find the way to solve.
(ex. special character & -> /amp )

please help me find the way..

SyntaxError: Invalid regular expression: /^([p{Alphabetic}p{Mark}p{Decimal_Number}p{Connector_Punctuation}p{Join_Control}]+)/: Invalid escape
    at new RegExp (<anonymous>)
    at Object.createWordRegex (/home/minieyes85/node_modules/sql-formatter/lib/core/regexFactory.js:38:10)
    at new Tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/core/Tokenizer.js:74:36)
    at StandardSqlFormatter.tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/languages/StandardSqlFormatter.js:57:14)
    at StandardSqlFormatter.format (/home/minieyes85/node_modules/sql-formatter/lib/core/Formatter.js:87:26)
    at Object.format (/home/minieyes85/node_modules/sql-formatter/lib/sqlFormatter.js:74:29)
    at MybatisMapper.getStatement (/home/minieyes85/node_modules/mybatis-mapper/index.js:109:32)
    at router.get (/home/minieyes85/routes/main.js:51:28)
    at Layer.handle [as handle_request] (/home/minieyes85/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/minieyes85/node_modules/express/lib/router/route.js:144:13)

checked preference setting of vscode text-editor encoding -> utf-8

open the web page without error

3

Answers


  1. Chosen as BEST ANSWER
    const mysql = require('mysql2');
    const mybatisMapper = require('mybatis-mapper');
    
    // create the connection to database
    const connection = mysql.createConnection({
        host: 'localhost',
        user: 'root',
        database: 'test'
    });
        
    // create the myBatisMapper from xml file
    mybatisMapper.createMapper([ './fruits.xml' ]);
        
    // SQL Parameters
    var param = {
        category : 'apple',
        price : 100
    }
        
    // Get SQL Statement
    var format = {language: 'sql', indent: '  '};
    var query = mybatisMapper.getStatement('fruit', 'testBasic', param, format);
        
    // Do it!
    connection.query(query, function(err, results, fields) {
        console.log(results); 
        console.log(fields);
    });
    

    in above code, var format <- this variable is problem in ubuntu, so I deleted var format and write code as like mybatisMapper.getStatement("","",param) without foramt.


  2. yes because syntax error
    at new RegExp ()
    at Object.createWordRegex (/home/minieyes85/node_modules/sql-formatter/lib/core/regexFactory.js:38:10)
    at new Tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/core/Tokenizer.js:74:36)
    at StandardSqlFormatter.tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/languages/StandardSqlFormatter.js:57:14)
    at StandardSqlFormatter.format (/home/minieyes85/node_modules/sql-formatter/lib/core/Formatter.js:87:26)
    at Object.format (/home/minieyes85/node_modules/sql-formatter/lib/sqlFormatter.js:74:29)
    at MybatisMapper.getStatement

    Login or Signup to reply.
  3. yes because syntax error at new RegExp () at Object.createWordRegex (/home/minieyes85/node_modules/sql-formatter/lib/core/regexFactory.js:38:10) at new Tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/core/Tokenizer.js:74:36) at StandardSqlFormatter.tokenizer (/home/minieyes85/node_modules/sql-formatter/lib/languages/StandardSqlFormatter.js:57:14) at StandardSqlFormatter.format (/home/minieyes85/node_modules/sql-formatter/lib/core/Formatter.js:87:26) at Object.format (/home/minieyes85/node_modules/sql-formatter/lib/sqlFormatter.js:74:29) at MybatisMapper.getStatement

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search