@@ -1564,3 +1564,98 @@ func TestFileServerWithOverlap(t *testing.T) {
15641564
15651565 Shutdown ()
15661566}
1567+
1568+ func TestUnicodeDatabaseName (t * testing.T ) {
1569+ // Test for Issue #57: Unicode database names should work properly
1570+ os .Remove ("../test/数据库.db" )
1571+
1572+ cfg := config {
1573+ Bindhost : "0.0.0.0" ,
1574+ Port : 12321 ,
1575+ Databases : []db {
1576+ {
1577+ Id : "数据库" ,
1578+ Path : "../test/数据库.db" ,
1579+ },
1580+ },
1581+ }
1582+ go launch (cfg , true )
1583+
1584+ time .Sleep (time .Second )
1585+
1586+ if ! fileExists ("../test/数据库.db" ) {
1587+ t .Error ("Unicode db file not created" )
1588+ return
1589+ }
1590+
1591+ // Create a table
1592+ req := request {
1593+ Transaction : []requestItem {
1594+ {
1595+ Statement : "CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)" ,
1596+ },
1597+ },
1598+ }
1599+
1600+ code , _ , res := call ("数据库" , req , t )
1601+
1602+ if code != 200 {
1603+ t .Error ("Create table failed with code" , code )
1604+ return
1605+ }
1606+
1607+ if ! res .Results [0 ].Success {
1608+ t .Error ("Create table did not succeed" )
1609+ return
1610+ }
1611+
1612+ // Insert data
1613+ req = request {
1614+ Transaction : []requestItem {
1615+ {
1616+ Statement : "INSERT INTO test (name) VALUES ('test data')" ,
1617+ },
1618+ },
1619+ }
1620+
1621+ code , _ , res = call ("数据库" , req , t )
1622+
1623+ if code != 200 {
1624+ t .Error ("Insert failed with code" , code )
1625+ return
1626+ }
1627+
1628+ if ! res .Results [0 ].Success {
1629+ t .Error ("Insert did not succeed" )
1630+ return
1631+ }
1632+
1633+ // Query data
1634+ req = request {
1635+ Transaction : []requestItem {
1636+ {
1637+ Query : "SELECT * FROM test" ,
1638+ },
1639+ },
1640+ }
1641+
1642+ code , _ , res = call ("数据库" , req , t )
1643+
1644+ if code != 200 {
1645+ t .Error ("Query failed with code" , code )
1646+ return
1647+ }
1648+
1649+ if ! res .Results [0 ].Success {
1650+ t .Error ("Query did not succeed" )
1651+ return
1652+ }
1653+
1654+ if len (res .Results [0 ].ResultSet ) != 1 {
1655+ t .Error ("Expected 1 row, got" , len (res .Results [0 ].ResultSet ))
1656+ return
1657+ }
1658+
1659+ Shutdown ()
1660+ os .Remove ("../test/数据库.db" )
1661+ }
0 commit comments