Any good library should provide proper escaping of SQL names, which include:
- schema name
- table name
- column name
For example, in pg-promise you should use it like this:
db.query("INSERT INTO $1~ VALUES ($2, $3, $4)", [table_name, value_a, value_b, value_c])
i.e. you will get the proper escaping of your table name by adding a variable with ~ , which in turn makes it safe from SQL injection.
From here , a simple escaping for table names executed by the library:
return '"' + name.replace(/"/g, '""') + '"';
See also: SQL Names
source share