New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: PG doesn't accept null bytes in UTF8 #284

Closed
anp opened this Issue Apr 19, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@anp
Contributor

anp commented Apr 19, 2016

It would be good to document the fact that diesel doesn't sanitize 0x00 from Rust's String type, which causes a runtime error when using the postgres backend. Also would be good to mention that it's problematic from an API perspective, as it would add non-trivial overhead to String serialization, along with low-overhead strategies for mitigating.

Maybe this could be a part of either a document on various backend idiosyncrasies, or possibly a document covering the various Rust type -> SQL type mappings that diesel supports.

@hiimtaylorjones

This comment has been minimized.

hiimtaylorjones commented May 10, 2016

I'm down to write some docs about this.

@dikaiosune - could you maybe provide some common examples where this might occur?

I really like the suggestion of documenting what Rust.to.SQL mappings are currently supported by Diesel. I think it'll bring down the amount of Issues of "Why doesn't rust_thing convert to SQL?" in the future.

@anp

This comment has been minimized.

Contributor

anp commented May 10, 2016

@hiimtaylorjones It came up for me when I was inserting responses from GitHub's API into the database. Still not sure why the heck GitHub was returning null bytes, but it is valid UTF-8, even though (apparently) Postgres doesn't accept null bytes.

I've been thinking about writing something similar, but my plate's a little full at the moment.

@sgrif

This comment has been minimized.

Member

sgrif commented May 10, 2016

Also to clarify, this only affects PG not the text type in general. SQLite handles nul bytes fine.

@hiimtaylorjones

This comment has been minimized.

hiimtaylorjones commented May 12, 2016

@dikaiosune - Sweet. I'll see what I can dig up there.

@sgrif - noted.

@hiimtaylorjones

This comment has been minimized.

hiimtaylorjones commented Feb 17, 2017

Hey everyone,

This totally fell of my radar. For that, I apologize. Though this conversation is about a year old, I decided to still take a shot at the issue.

While, the need for SQL mapping types still exists, I figured that I'd at least write up something to cover the ground in the meantime. That commit can be found here. Please let me know if I'm completely right, wrong, or somewhere in between!

As far as the proposed mapping documentation is concerned, where exactly would be the best place to insert that documentation?

@killercup killercup added this to API docs in Documentation Feb 17, 2017

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 5, 2017

This is now documented on the Text type. It may be worth documenting elsewhere, but this issue seems resolved for the time being.

@sgrif sgrif closed this Dec 5, 2017

@sgrif sgrif removed this from API docs in Documentation Jan 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment