Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Hardcoded strings are being cut in half #98

Open
vasa-chi opened this Issue · 4 comments

3 participants

@vasa-chi

When I select values from tables with cyrillic data, everything is fine, but if I call a procudure like this:

CREATE OR REPLACE PROCEDURE TEST_ENCODING 
(
  CUR OUT SYS_REFCURSOR 
) AS 
BEGIN
  open cur for
  select 'тест' as hello from dual; -- cyrillic hardcoded text
END TEST_ENCODING;
call TEST_ENCODING(:1) -- using new oracle.OutParam(oracle.OCCICURSOR)

result is:

[ { HELLO: 'те' } ]

The database is configured as follows:

NLS_LANGUAGE    AMERICAN
NLS_TERRITORY   AMERICA
NLS_CURRENCY    $
NLS_ISO_CURRENCY    AMERICA
NLS_NUMERIC_CHARACTERS  .,
NLS_CHARACTERSET    CL8MSWIN1251
NLS_CALENDAR    GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE   AMERICAN
NLS_SORT    BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT    DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT  HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY   $
NLS_COMP    BINARY
NLS_LENGTH_SEMANTICS    BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET  AL16UTF16
NLS_RDBMS_VERSION   11.2.0.3.0

In my local env: NLS_LANG=AMERICAN_AMERICA.UTF8
(also tried NLS_LANG=RUSSIAN_RUSSIA.UTF8 and RUSSIAN_RUSSIA.AL32UTF8 with same results)

upd.
Mac OS X 10.9
Oracle Client 11.2
node-oracle 0.3.4

@vasa-chi

Anyone?

@raztus
Collaborator

I'm unable to reproduce your result using Oracle Express 10g, node 0.10.22, and node-oracle 0.3.5 or master. I ran your exact code to create the procedure from Oracle SQL Developer, then ran the following Javascript:

connection.execute("call TEST_ENCODING(:1)", [new oracle.OutParam(oracle.OCCICURSOR)], function(err, results) {
    console.log(results);
});

Which gives me this output (using any of the NLS_LANG settings you described):

{ updateCount: 0, returnParam: [ { HELLO: 'тест' } ] }

@raztus
Collaborator

Your issue exposed another long-standing problem with utf8 characters in the SQL query value, where the following code would return the ASCII value, rather than the original Cyrillic string:

connection.execute("SELECT 'тест' as test FROM DUAL", [], function(err, results) {
  console.log(results); // Previously output "B5AB"
}

This has now been fixed in commit c257b30

@paulish

Cant confirm:

integration.js
✔ IntegrationTest - select with single quote
✔ IntegrationTest - insert with returning value
✔ IntegrationTest - datatypes
✔ IntegrationTest - datatypes null
✔ IntegrationTest - date_types_insert_milliseconds
✔ IntegrationTest - prepare statement
✖ IntegrationTest - utf8_chars_in_query

Assertion Message: UTF8 characters in sql query should be preserved
AssertionError: 'те' == 'тест'
at Object.equal (D:\programming\ws3\www\monitoring\node_modules\oracle\node_modules\nodeunit\lib\types.js:83:39)
at D:\programming\ws3\www\monitoring\node_modules\oracle\test\integration.js:227:12

This issue is related to #213 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.