Skip to content

Commit 36e1946

Browse files
committed
Expose column types.
1 parent 7342e38 commit 36e1946

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/db/mariadb/connection.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ def key_column(name = 'id', primary: true, null: false)
8787
return buffer
8888
end
8989

90+
COLUMN_TYPES = {
91+
Integer => 'BIGINT',
92+
Float => 'DOUBLE',
93+
String => 'TEXT',
94+
Time => 'DATETIME',
95+
Date => 'DATE',
96+
}
97+
98+
def column_types
99+
COLUMN_TYPES
100+
end
101+
90102
def status
91103
@native.status
92104
end

test/db/mariadb/connection.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,18 @@
9393
connection.close
9494
end
9595
end
96+
97+
with '#column_types' do
98+
it "has column types for general types" do
99+
expect(connection.column_types).to be_a(Hash)
100+
101+
column_types = connection.column_types
102+
103+
expect(column_types).to have_keys(
104+
Integer, Float, String, Time, Date
105+
)
106+
ensure
107+
connection.close
108+
end
109+
end
96110
end

0 commit comments

Comments
 (0)