diff --git a/CHANGELOG.md b/CHANGELOG.md index 69eb70d..03ac821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1 (unreleased) + +- Fixed `operator is not unique` error + ## 0.2.0 (2021-10-03) - Added support for Postgres 14 diff --git a/sql/vector--0.2.0--0.2.1.sql b/sql/vector--0.2.0--0.2.1.sql new file mode 100644 index 0000000..55e76de --- /dev/null +++ b/sql/vector--0.2.0--0.2.1.sql @@ -0,0 +1,19 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "ALTER EXTENSION vector UPDATE TO '0.2.1'" to load this file. \quit + +DROP CAST (integer[] AS vector); +DROP CAST (real[] AS vector); +DROP CAST (double precision[] AS vector); +DROP CAST (numeric[] AS vector); + +CREATE CAST (integer[] AS vector) + WITH FUNCTION array_to_vector(integer[], integer, boolean) AS ASSIGNMENT; + +CREATE CAST (real[] AS vector) + WITH FUNCTION array_to_vector(real[], integer, boolean) AS ASSIGNMENT; + +CREATE CAST (double precision[] AS vector) + WITH FUNCTION array_to_vector(double precision[], integer, boolean) AS ASSIGNMENT; + +CREATE CAST (numeric[] AS vector) + WITH FUNCTION array_to_vector(numeric[], integer, boolean) AS ASSIGNMENT; diff --git a/sql/vector.sql b/sql/vector.sql index 452154f..6f89c1f 100644 --- a/sql/vector.sql +++ b/sql/vector.sql @@ -109,16 +109,16 @@ CREATE CAST (vector AS vector) WITH FUNCTION vector(vector, integer, boolean) AS IMPLICIT; CREATE CAST (integer[] AS vector) - WITH FUNCTION array_to_vector(integer[], integer, boolean) AS IMPLICIT; + WITH FUNCTION array_to_vector(integer[], integer, boolean) AS ASSIGNMENT; CREATE CAST (real[] AS vector) - WITH FUNCTION array_to_vector(real[], integer, boolean) AS IMPLICIT; + WITH FUNCTION array_to_vector(real[], integer, boolean) AS ASSIGNMENT; CREATE CAST (double precision[] AS vector) - WITH FUNCTION array_to_vector(double precision[], integer, boolean) AS IMPLICIT; + WITH FUNCTION array_to_vector(double precision[], integer, boolean) AS ASSIGNMENT; CREATE CAST (numeric[] AS vector) - WITH FUNCTION array_to_vector(numeric[], integer, boolean) AS IMPLICIT; + WITH FUNCTION array_to_vector(numeric[], integer, boolean) AS ASSIGNMENT; CREATE CAST (vector AS real[]) WITH FUNCTION vector_to_float4(vector, integer, boolean) AS IMPLICIT; diff --git a/test/expected/functions.out b/test/expected/functions.out index 930a60e..8a2efb7 100644 --- a/test/expected/functions.out +++ b/test/expected/functions.out @@ -54,3 +54,9 @@ SELECT cosine_distance('[1,2]', '[0,0]'); SELECT cosine_distance('[1,2]', '[3]'); ERROR: different vector dimensions 2 and 1 +SELECT ARRAY[1,2,3] = ARRAY[1,2,3]; + ?column? +---------- + t +(1 row) + diff --git a/test/sql/functions.sql b/test/sql/functions.sql index 7f397a2..adb7695 100644 --- a/test/sql/functions.sql +++ b/test/sql/functions.sql @@ -16,3 +16,5 @@ SELECT inner_product('[1,2]', '[3]'); SELECT round(cosine_distance('[1,2]', '[2,4]')::numeric, 5); SELECT cosine_distance('[1,2]', '[0,0]'); SELECT cosine_distance('[1,2]', '[3]'); + +SELECT ARRAY[1,2,3] = ARRAY[1,2,3];