Surreal-Net / Surreal.Net

Database driver for SurrealDB available for REST and RPC sessions.
Apache License 2.0
57 stars 7 forks source link

Bug: Objects with a newline in the string cannot be created by DbRpc #20

Closed Du-z closed 1 year ago

Du-z commented 1 year ago

Cannot insert a object with a string that contains a new line character.

Uncomment the following line and run the test RpcRoundTripTests.CreateRoundTripTest

https://github.com/ProphetLamb/Surreal.Net/blob/3ed84b191f60a98dd82837beec744d3e71129ae6/tests/Core.Tests/RoundTripTests.cs#L120

ProphetLamb commented 1 year ago

This is related to an issue in the database engine https://github.com/surrealdb/surrealdb/issues/137 & https://github.com/surrealdb/surrealdb/issues/90. SurrealDB does not accept any ascii and unicode escape sequences. The workaround is not to serialize escape sequences. A sideaffect is that C-escape-sequences are not escaped aswell: https://github.com/ProphetLamb/Surreal.Net/blob/71bc7d426f8087b04fccfee86b69dd07b1d1e2fe/src/Driver/Util.cs#L881-L882

ProphetLamb commented 1 year ago

Can be solved by wrapping the JavaScriptEncoder.UnsafeRelaxedJsonEscaping and handling c-escape-sequences manually

tobiemh commented 1 year ago

Hi @ProphetLamb , and @Du-z that's probably because of this bug https://github.com/surrealdb/surrealdb/issues/90

Should be fixed soon...

ProphetLamb commented 1 year ago

Blocked until https://github.com/surrealdb/surrealdb/issues/90 is in release

ProphetLamb commented 1 year ago

This should work now! I am looking at other fixed testcases over at #72