Skip to content

Commit

Permalink
Send MYSQL_TYPE_BIT and MYSQL_TYPE_GEOMETRY as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Nov 9, 2020
1 parent 077b32e commit 887e3a4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/myxql/protocol/values.ex
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ defmodule MyXQL.Protocol.Values do
size = bit_size(bitstring)
pad = 8 - rem(size, 8)
bitstring = <<0::size(pad), bitstring::bitstring>>
{:mysql_type_bit, encode_string_lenenc(bitstring)}
{:mysql_type_var_string, encode_string_lenenc(bitstring)}
end

def encode_binary_value(true) do
Expand Down Expand Up @@ -269,7 +269,7 @@ defmodule MyXQL.Protocol.Values do
defp encode_geometry(geo) do
srid = geo.srid || 0
binary = %{geo | srid: nil} |> Geo.WKB.encode!(:ndr) |> Base.decode16!()
{:mysql_type_geometry, encode_string_lenenc(<<srid::uint4, binary::binary>>)}
{:mysql_type_var_string, encode_string_lenenc(<<srid::uint4, binary::binary>>)}
end
end

Expand Down
3 changes: 1 addition & 2 deletions test/myxql/protocol/values_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ defmodule MyXQL.Protocol.ValueTest do
assert_roundtrip(c, "my_year", 1999)
end

@tag bit: true
test "MYSQL_TYPE_BIT", c do
assert_roundtrip(c, "my_bit3", <<1::1, 0::1, 1::1>>)
assert_roundtrip(c, "my_bit3", <<1::1, 0::1, 0::1>>)
Expand Down Expand Up @@ -326,7 +325,7 @@ defmodule MyXQL.Protocol.ValueTest do
@tag geometry: true
test "MULTIPOINT", c do
assert_roundtrip(c, "my_multipoint", %Geo.MultiPoint{
coordinates: [{1.0, 1.0}, {2.0, 2.0}]
coordinates: List.duplicate({1.0, 1.0}, 1024)
})
end

Expand Down
9 changes: 0 additions & 9 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@ defmodule TestHelper do
def excludes() do
supported_auth_plugins = [:mysql_native_password, :sha256_password, :caching_sha2_password]
available_auth_plugins = available_auth_plugins()
[%{"@@version" => version}] = mysql!("select @@version")
mariadb? = version =~ ~r"mariadb"i

mariadb_exclude = [
# for both bit and geometry, inserting with wire protocol does not work for some reason
bit: true,
geometry: true
]

exclude =
for plugin <- supported_auth_plugins,
Expand All @@ -270,7 +262,6 @@ defmodule TestHelper do
exclude = [{:json, not supports_json?()} | exclude]
exclude = [{:geometry, not supports_geometry?()} | exclude]
exclude = [{:timestamp_precision, not supports_timestamp_precision?()} | exclude]
exclude = if mariadb?, do: Keyword.merge(exclude, mariadb_exclude), else: exclude
exclude
end
end
Expand Down

0 comments on commit 887e3a4

Please sign in to comment.