oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.26k stars 1.08k forks source link

Add option to set character set #1172

Closed natlibfi-arlehiko closed 4 years ago

natlibfi-arlehiko commented 5 years ago
  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
anthony-tuininga commented 5 years ago

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?

anthony-tuininga commented 5 years ago

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 5 years ago

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

cjbj commented 5 years ago

@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 5 years ago

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

cjbj commented 5 years ago

@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 5 years ago

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

lfpei commented 5 years ago

@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 5 years ago

@cjbj How do i handle US7ASCII in nodejs code

natlibfi-arlehiko commented 5 years ago

@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 5 years ago

@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 5 years ago

@cjbj I've created a new problem.

1175

cjbj commented 5 years ago

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

natlibfi-arlehiko commented 4 years ago

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

cjbj commented 4 years ago

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