-
Notifications
You must be signed in to change notification settings - Fork 312
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
lib/ecto/adapters/myxql/connection.ex: refactored improper lists #587
Conversation
…tring literals, 1 variable with is_binary guard, last 4 were Integer.to_string
Hi @bradhanks , Improper lists are 100% intentional. They save some bytes when sending the query string to the database. |
oh nice. learned something new :) |
Sorry I mixed up the adapter behaviour with the driver behaviour (Postgrex, etc.). In this case it's not about sending it to the database but rather this construct will be immediately passed to |
Just to solidify my own understanding, if you don't mind, are there issues with the below statement? There's really no issue using a cons operator to add a string to the end of an iolist. The list isn't improper if all the elements are binaries. |
It looks like there is a slight misunderstanding in it. An improper list isn't about whether the elements are binaries but whether the last element's tail is the empty list. Every proper list can be represented as Where binaries play a special role is in iolists. This is the definition from erlang:
So when creating an improper list inside of an iolist, the last tail can be a binary but not an integer. |
ok so an iolist can be improper or proper depending on if it ends in an empty list or binary. |
Yeah that is correct. |
|
refactored 10 lists
5 had a string literal as the tail
1 was a variable with a is_binary guard
4 were Integer.to_string functions