-
Notifications
You must be signed in to change notification settings - Fork 82
Encode query params in binary instead of text #295
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ enum EncoderSpec::Status | |
| end | ||
|
|
||
| private def test_insert_and_read(datatype, value, file = __FILE__, line = __LINE__) | ||
| it "inserts #{datatype}", file, line do | ||
| it "inserts #{value.inspect} as #{datatype}", file, line do | ||
| PG_DB.exec "drop table if exists test_table" | ||
| PG_DB.exec "create table test_table (v #{datatype})" | ||
| PG_DB.exec "insert into test_table values ($1)", args: [value] | ||
|
|
@@ -18,11 +18,18 @@ private def test_insert_and_read(datatype, value, file = __FILE__, line = __LINE | |
| end | ||
|
|
||
| describe PG::Driver, "encoder" do | ||
| test_insert_and_read "int4", 123 | ||
| test_insert_and_read "boolean", true | ||
| test_insert_and_read "boolean", false | ||
|
|
||
| test_insert_and_read "float", 12.34 | ||
| test_insert_and_read "int2", 123i16 | ||
| test_insert_and_read "int4", 123i32 | ||
| test_insert_and_read "int8", 123i64 | ||
|
|
||
| test_insert_and_read "float4", 12.34f32 | ||
| test_insert_and_read "float8", 12.34f64 | ||
|
Comment on lines
-23
to
+29
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I don't specify the sizes of numeric types, I get errors that I don't understand yet. I figured I'd look into it later. Spec errors |
||
|
|
||
| test_insert_and_read "varchar", "hello world" | ||
| test_insert_and_read "text", "hello world" | ||
will marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test_insert_and_read "timestamp", Time.utc(2015, 2, 3, 17, 15, nanosecond: 13_000_000) | ||
| test_insert_and_read "timestamp", Time.utc(2015, 2, 3, 17, 15, 13, nanosecond: 11_000_000) | ||
|
|
@@ -32,18 +39,24 @@ describe PG::Driver, "encoder" do | |
| test_insert_and_read "int4", EncoderSpec::Status::Open | ||
| test_insert_and_read "int4", EncoderSpec::Status::Closed | ||
|
|
||
| test_insert_and_read "bool[]", [] of Bool | ||
| test_insert_and_read "bool[]", [true] | ||
| test_insert_and_read "bool[]", [false] | ||
| test_insert_and_read "bool[]", [true, false, true] | ||
will marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test_insert_and_read "float[]", [1.2, 3.4, 5.6] | ||
|
|
||
| test_insert_and_read "integer[]", [] of Int32 | ||
| test_insert_and_read "integer[]", [1, 2, 3] | ||
| test_insert_and_read "integer[]", [[1, 2], [3, 4]] | ||
| test_insert_and_read "integer[][]", [[1, 2], [3, 4]] | ||
| test_insert_and_read "integer[][][]", [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] | ||
|
Comment on lines
49
to
+52
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was actually surprised that the |
||
|
|
||
| test_insert_and_read "text[]", ["t", "f", "t"] | ||
| test_insert_and_read "text[]", ["non-nil value", nil] | ||
| test_insert_and_read "text[]", [%("a), %(\\b~), %(c\\"d), %(\uFF8F)] | ||
| test_insert_and_read "text[]", ["baz, bar"] | ||
| test_insert_and_read "text[]", ["foo}"] | ||
| test_insert_and_read "text[][]", [["foo", "bar"], ["baz", "quux"]] | ||
|
|
||
| test_insert_and_read "interval", PG::Interval.new | ||
| test_insert_and_read "interval", PG::Interval.new(days: 400, microseconds: 5000000) | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -501,7 +501,8 @@ module PG | |
| end | ||
| end | ||
|
|
||
| @@decoders = Hash(Int32, PG::Decoders::Decoder).new(ByteaDecoder.new) | ||
| # :nodoc: | ||
| class_getter decoders = Hash(Int32, PG::Decoders::Decoder).new(ByteaDecoder.new) | ||
|
Comment on lines
-504
to
+505
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this because I was going to use decoders as the source for oids, but I didn't end up using it. I can probably undo this change. |
||
|
|
||
| def self.from_oid(oid) | ||
| @@decoders[oid] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.