@@ -973,6 +973,68 @@ export function runCommonTests(client: Client) {
973973 await attachment . dropDatabase ( ) ;
974974 } ) ;
975975
976+ test ( 'NONE charset uses charSetForNONE for read/write' , async ( ) => {
977+ const filename = getTempFile ( 'ResultSet-none-charset.fdb' ) ;
978+
979+ {
980+ const attachment = await client . createDatabase ( filename ) ;
981+ const transaction = await attachment . startTransaction ( ) ;
982+ await attachment . execute ( transaction , 'create table t1 (id integer, x varchar(10) character set none)' ) ;
983+ await transaction . commitRetaining ( ) ;
984+ await attachment . execute (
985+ transaction ,
986+ "insert into t1 (id, x) values (1, cast(x'B99C9F' as varchar(3) character set none))" ,
987+ ) ;
988+ await attachment . execute (
989+ transaction ,
990+ "insert into t1 (id, x) values (2, cast(x'B1B6BC' as varchar(3) character set none))" ,
991+ ) ;
992+ await transaction . commit ( ) ;
993+ await attachment . disconnect ( ) ;
994+ }
995+
996+ {
997+ const attachment = await client . connect ( filename ) ;
998+ const transaction = await attachment . startTransaction ( ) ;
999+ const row1 = await attachment . executeSingleton ( transaction , 'select x from t1 where id = 1' ) ;
1000+ const row2 = await attachment . executeSingleton ( transaction , 'select x from t1 where id = 2' ) ;
1001+ expect ( row1 [ 0 ] ) . toBe ( Buffer . from ( 'b99c9f' , 'hex' ) . toString ( 'utf8' ) ) ;
1002+ expect ( row2 [ 0 ] ) . toBe ( Buffer . from ( 'b1b6bc' , 'hex' ) . toString ( 'utf8' ) ) ;
1003+ await transaction . commit ( ) ;
1004+ await attachment . disconnect ( ) ;
1005+ }
1006+
1007+ {
1008+ const attachment = await client . connect ( filename , { charSetForNONE : 'windows-1250' } ) ;
1009+ const transaction = await attachment . startTransaction ( ) ;
1010+ const row = await attachment . executeSingleton ( transaction , 'select x from t1 where id = 1' ) ;
1011+ expect ( row [ 0 ] ) . toBe ( 'ąśź' ) ;
1012+ await attachment . execute ( transaction , 'insert into t1 (id, x) values (?, ?)' , [ 101 , 'ąśź' ] ) ;
1013+ const check = await attachment . executeSingleton (
1014+ transaction ,
1015+ "select count(*) from t1 where id = 101 and x = cast(x'B99C9F' as varchar(3) character set none)" ,
1016+ ) ;
1017+ expect ( check [ 0 ] ) . toBe ( 1 ) ;
1018+ await transaction . commit ( ) ;
1019+ await attachment . disconnect ( ) ;
1020+ }
1021+
1022+ {
1023+ const attachment = await client . connect ( filename , { charSetForNONE : 'iso-8859-2' } ) ;
1024+ const transaction = await attachment . startTransaction ( ) ;
1025+ const row = await attachment . executeSingleton ( transaction , 'select x from t1 where id = 2' ) ;
1026+ expect ( row [ 0 ] ) . toBe ( 'ąśź' ) ;
1027+ await attachment . execute ( transaction , 'insert into t1 (id, x) values (?, ?)' , [ 201 , 'ąśź' ] ) ;
1028+ const check = await attachment . executeSingleton (
1029+ transaction ,
1030+ "select count(*) from t1 where id = 201 and x = cast(x'B1B6BC' as varchar(3) character set none)" ,
1031+ ) ;
1032+ expect ( check [ 0 ] ) . toBe ( 1 ) ;
1033+ await transaction . commit ( ) ;
1034+ await attachment . dropDatabase ( ) ;
1035+ }
1036+ } ) ;
1037+
9761038 test ( '#fetch() with fetchSize' , async ( ) => {
9771039 const attachment = await client . createDatabase ( getTempFile ( 'ResultSet-fetch-with-fetchSize.fdb' ) ) ;
9781040 const transaction = await attachment . startTransaction ( ) ;
0 commit comments