Skip to content

Commit b02d192

Browse files
committed
Fix typespecs, add structs tests
1 parent ff0883e commit b02d192

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

lib/adbc_column.ex

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,54 +35,54 @@ defmodule Adbc.Column do
3535
@type precision256 :: 1..76
3636
@type decimal128 :: {:decimal, 128, precision128(), integer()}
3737
@type decimal256 :: {:decimal, 256, precision256(), integer()}
38-
@type decimal_t ::
38+
@type decimal ::
3939
decimal128
4040
| decimal256
4141
@type time_unit ::
4242
:seconds
4343
| :milliseconds
4444
| :microseconds
4545
| :nanoseconds
46-
@type time32_t ::
46+
@type time32 ::
4747
{:time32, :seconds}
4848
| {:time32, :milliseconds}
49-
@type time64_t ::
49+
@type time64 ::
5050
{:time64, :microseconds}
5151
| {:time64, :nanoseconds}
52-
@type time_t :: time32_t() | time64_t()
53-
@type timestamp_t ::
52+
@type time :: time32() | time64()
53+
@type timestamp ::
5454
{:timestamp, :seconds, String.t()}
5555
| {:timestamp, :milliseconds, String.t()}
5656
| {:timestamp, :microseconds, String.t()}
5757
| {:timestamp, :nanoseconds, String.t()}
58-
@type duration_t ::
58+
@type duration ::
5959
{:duration, :seconds}
6060
| {:duration, :milliseconds}
6161
| {:duration, :microseconds}
6262
| {:duration, :nanoseconds}
6363
@type interval_month :: s32()
64-
@type interval_day_time :: {s32(), s32()}
64+
@type interval_day_xime :: {s32(), s32()}
6565
@type interval_month_day_nano :: {s32(), s32(), s64()}
6666
@type interval_unit ::
6767
:month
6868
| :day_time
6969
| :month_day_nano
70-
@type interval_t ::
70+
@type interval ::
7171
{:interval, :month}
7272
| {:interval, :day_time}
7373
| {:interval, :month_day_nano}
7474
@list_view_types [
7575
:list_view,
7676
:large_list_view
7777
]
78-
@type list_view_data_t :: %{
78+
@type list_view_data :: %{
7979
validity: [boolean()],
8080
offsets: [non_neg_integer()],
8181
sizes: [non_neg_integer()],
8282
values: %Adbc.Column{}
8383
}
8484
@valid_run_end_types [:s16, :s32, :s64]
85-
@type dictionary_data_t :: %{
85+
@type dictionary_data :: %{
8686
key: %Adbc.Column{},
8787
value: %Adbc.Column{}
8888
}
@@ -100,18 +100,18 @@ defmodule Adbc.Column do
100100
| :large_binary
101101
| :string
102102
| :large_string
103-
| decimal_t
103+
| decimal
104104
| {:fixed_size_binary, non_neg_integer()}
105-
| :struct
105+
| {:struct, %Adbc.Column{}}
106106
| :date32
107107
| :date64
108-
| time_t
109-
| timestamp_t
110-
| duration_t
111-
| interval_t
108+
| time
109+
| timestamp
110+
| duration
111+
| interval
112112
| :run_end_encoded
113113
| :dictionary
114-
@spec column(data_type(), list() | list_view_data_t() | dictionary_data_t(), Keyword.t()) ::
114+
@spec column(data_type(), list() | list_view_data() | dictionary_data(), Keyword.t()) ::
115115
%Adbc.Column{}
116116
def column(type, data, opts \\ [])
117117
when (is_atom(type) or is_tuple(type)) and
@@ -1009,7 +1009,7 @@ defmodule Adbc.Column do
10091009
* `:metadata` - A map of metadata
10101010
"""
10111011
@spec interval(
1012-
[interval_month() | interval_day_time() | interval_month_day_nano() | nil],
1012+
[interval_month() | interval_day_xime() | interval_month_day_nano() | nil],
10131013
interval_unit(),
10141014
Keyword.t()
10151015
) ::

test/adbc_test.exs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,39 @@ defmodule AdbcTest do
402402
assert Exception.message(error) =~ "Parser Error"
403403
end
404404

405+
test "structs", %{conn: conn} do
406+
assert %Adbc.Result{
407+
data: [
408+
%Adbc.Column{
409+
name: "struct_pack(col1 := 1, col2 := 2)",
410+
type:
411+
{:struct,
412+
[
413+
%Adbc.Column{
414+
name: "col1",
415+
type: :s32,
416+
nullable: true,
417+
metadata: nil,
418+
data: nil,
419+
length: nil,
420+
offset: nil
421+
},
422+
%Adbc.Column{
423+
name: "col2",
424+
type: :s32,
425+
nullable: true,
426+
metadata: nil,
427+
data: nil,
428+
length: nil,
429+
offset: nil
430+
}
431+
]}
432+
}
433+
],
434+
num_rows: 0
435+
} = Adbc.Connection.query!(conn, "SELECT struct_pack(col1 := 1, col2 := 2)")
436+
end
437+
405438
test "decimal128", %{conn: conn} do
406439
d1 = Decimal.new("1.2345678912345678912345678912345678912")
407440
d2 = Decimal.new("-1.2345678912345678912345678912345678912")

0 commit comments

Comments
 (0)