sqorn/sqorn

Library auto converting column names to snake case.

Closed this issue · 1 comments

I am not sure if there's a supported workaround for this issue, but still I would like to understand what could be done to mitigate this. I will be explaining my issue with an example to convey it better.

const { text, args } = sq.fromorders.where({CustomerID: 'FRANK'}).joinorder_details.onorders.OrderID=order_details.OrderID.joinproducts.onorder_details.ProductID=products.ProductID.where({ProductName: 'Tofu'}).query;

This line yields the following string in text, but CustomerID and ProductName were converted to SnakeCase implicitly which makes sense because pg recommends snake cased column names but this is not a strict convention AFAIK and it would be good if library doesn't auto convert, instead escape it.

"select * from orders join order_details on (orders.OrderID=order_details.OrderID) join products on (order_details.ProductID=products.ProductID) where (customer_i_d = $1) and (product_name = $2)"

NB: This issue is partially related to #54

Customize this behavior by configuring mapInputKeys when initializing Sqorn. See https://sqorn.org/docs/configuration.html

// disables snake case conversion
const sq = sqorn({ mapInputKeys: key => key })