oracle/node-oracledb

Add option to set character set

natlibfi-arlehiko opened this issue · 15 comments

  1. Review existing enhancement requests

  2. Describe your new request in detail
    Currently, node-oracle has a static client charset (Node-oracledb always uses Oracle’s AL32UTF8 character set internally.). We have a problem with this since our DB has character data in LONG column which gets automatically converted to string. Since we cannot set the charset the UTF-8 data gets converted incorrectly.

Our workaround was to fork node-oracledb and odpi and change the default charset.

It'd be better if the node-oracledb would support setting the charset. I can create a PR if given directions how, and where this enhancement should be implemented.

Related issues: #223 , #533 #132 , #62

  1. Give supporting information about tools and operating systems. Give relevant product version numbers
    node-oracledb: 4.0.1

So what is your database character set? And why are you not storing your data in that character set? Since UTF-8 (aka AL32UTF8 for Oracle) is a universal character set it should be perfectly capable of encoding all characters. The only time this won't work is if your database character set is A and you are attempting to store your data in character set B, and the conversion between character set A and B is such that there is no character mangling. Of course, it also means that you must use character set B as your client character set at all times or character mangling takes place. That seems to be what you are talking about. Can you clarify?

Please also provide an example. Include the create table statement and some insert statements and the Node.js code that demonstrates the problem.

lfpei commented

我现在碰到一个情况,oracle server 用的US7ASCII ,客户端查询出来乱码,这个可以在连接数据库的时候直接设置字符集吗?

cjbj commented

@lfpei yes, node-oracledb will let you query data from a DB that is running US7ASCII. There is no need to change the client character set.

lfpei commented

@cjbj node-oracledb在链接数据库的时候需要修改什么配置?具体步骤麻烦告知下,谢谢

cjbj commented

@lfpei there are no specific steps because node-oracledb always queries data in AL32UTF8 which can handle ASCII data. If you have a specific problem with your data then open a new issue. Give us a runnable test case including SQL to create table data. It is better if you translate to English because I don't speak Mandarin.

cjbj commented

@natlibfi-arlehiko shouldn't you be using LONG RAW?

lfpei commented

@cjbj What configuration do I need to write in the code to make the character set US7ASCII,and There is no way for the server connect to the Internet, and there is no test environment code

lfpei commented

@cjbj How do i handle US7ASCII in nodejs code

@natlibfi-arlehiko shouldn't you be using LONG RAW?

Yes, of course :) But we cannot touch what our service does. We are only querying data and cannot affect how it's written to the database.

cjbj commented

@lfpei it sounds like you have some confusion, or an example that needs more explanation. There is nothing special that normal use of US7ASCII data from the DB would need. Please open a new issue.

@natlibfi-arlehiko we'll discuss adding an option, but personally I'm not in favor of extra complexity in node-oracledb just because a data model wasn't correctly chosen. The complexity and all the resultant testing (effectively more than doubling our test load) would need to be carried forward for all future versions so it's a significant change. You can help by providing the testcase that @anthony-tuininga asked for, to make sure we really understand what you want.

lfpei commented

@cjbj I've created a new problem.
#1175

cjbj commented

@natlibfi-arlehiko we discussed this and have no plans to change from a fixed AL32UTF8.

@cjbj Ok. But I'll still try to provide an example to further clarify this.

cjbj commented

Closing - there are no plans to move from the default character set.