Skip to content
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

map ecto :datetime to datetime2, clean up uuid, fix ddl test #12

Merged
merged 1 commit into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions lib/tds_ecto/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -627,30 +627,13 @@ if Code.ensure_loaded?(Tds.Connection) do
defp ecto_to_db(:binary_id), do: "uniqueidentifier"
defp ecto_to_db(:string), do: "nvarchar"
defp ecto_to_db(:binary), do: "varbinary"
defp ecto_to_db(:datetime), do: "datetime2"
defp ecto_to_db(:map), do: "nvarchar"
defp ecto_to_db(:boolean), do: "bit"
defp ecto_to_db(other), do: Atom.to_string(other)

defp uuid(binary) do
<<
p1::binary-size(1),
p2::binary-size(1),
p3::binary-size(1),
p4::binary-size(1),
p5::binary-size(1),
p6::binary-size(1),
p7::binary-size(1),
p8::binary-size(1),
p9::binary-size(1),
p10::binary-size(1),
p11::binary-size(1),
p12::binary-size(1),
p13::binary-size(1),
p14::binary-size(1),
p15::binary-size(1),
p16::binary-size(1)>> = binary

p4 <> p3 <> p2 <>p1 <> p6 <> p5 <> p8 <> p7 <> p9 <> p10 <> p11 <> p12 <> p13 <> p14 <> p15 <> p16
def uuid(<<v1::32, v2::16, v3::16, v4::64>>) do
<<v1::little-signed-32, v2::little-signed-16, v3::little-signed-16, v4::signed-64>>
end
end
end
2 changes: 1 addition & 1 deletion test/tds_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ defmodule Tds.Ecto.TdsTest do
{:add, :title, :string, []},
{:add, :created_at, :datetime, []}]}
assert SQL.execute_ddl(create) ==
~s|CREATE TABLE [posts] ([id] bigint NOT NULL PRIMARY KEY IDENTITY, [title] nvarchar(255) NULL, [created_at] datetime NULL)|
~s|CREATE TABLE [posts] ([id] bigint NOT NULL PRIMARY KEY IDENTITY, [title] nvarchar(255) NULL, [created_at] datetime2 NULL)|
end

test "create table with reference" do
Expand Down