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

Add Support For Postgres Full Text Search tsvector Data Type #2727

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7cc0566
WIP: Add Postgres TsVector And TsQuery Types #729,#2705
anshap1719 Mar 31, 2024
b6a93ca
WIP: Add Initial Decoding For TsVector #729,#2705
anshap1719 Aug 25, 2023
a2578ed
WIP: Add Link To TsVector Binary Data Format Information #2705
anshap1719 Aug 25, 2023
b603365
WIP: Add Initial Encoding For TsVector #729,#2705
anshap1719 Aug 25, 2023
b98a3eb
WIP: Remove Unimplemented TsQuery Definitions #2705
anshap1719 Aug 25, 2023
c4b2274
Revert "WIP: Remove Unimplemented TsQuery Definitions #2705"
anshap1719 Sep 1, 2023
6abc12f
WIP: Add Support For Decoding And Encoding TsQuery #2705
anshap1719 Sep 1, 2023
612a452
WIP: Add Missing Exports For TsQuery #2705
anshap1719 Sep 1, 2023
8071cac
WIP: Fix Build Issues, Add Tests For TsVector #729,#2705
anshap1719 Sep 2, 2023
032f8ba
Remove Feature Flag For Postgres Full Text Search Data Types #729,#2705
anshap1719 Mar 31, 2024
8166072
Update Type For Pg Argument Buffer #729,#2705
anshap1719 Mar 31, 2024
1ce2f7d
Run cargo fmt
anshap1719 Mar 31, 2024
bf67dfa
Add Support For Weights In Word Positions #729,#2705
anshap1719 Apr 8, 2024
65a8267
Fix Clippy Lint Warning #729,#2705
anshap1719 Apr 8, 2024
5ac77d0
Add Handling For Whitespace Inside TSVector Words #729,#2705
anshap1719 Apr 21, 2024
a85c27f
Remove Incomplete TSQuery Implementation #729,#2705
anshap1719 Apr 21, 2024
570216b
Add Proper Handling For Escaped And Non-Escaped Single Quotes In TSVe…
anshap1719 Apr 28, 2024
8e8c0f1
Remove All TSQuery Related DB Type Info Declarations #729,#2705
anshap1719 Apr 29, 2024
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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["any", "macros", "migrate", "json"]

derive = ["sqlx-macros/derive"]
macros = ["derive", "sqlx-macros/macros"]
migrate = ["sqlx-core/migrate", "sqlx-macros?/migrate", "sqlx-mysql?/migrate", "sqlx-postgres?/migrate", "sqlx-sqlite?/migrate"]
Expand All @@ -69,7 +68,7 @@ _unstable-all-types = [
"ipnetwork",
"mac_address",
"uuid",
"bit-vec",
"bit-vec"
]

# Base runtime features without TLS
Expand Down
4 changes: 4 additions & 0 deletions sqlx-postgres/src/type_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ impl_type_checking!(
#[cfg(feature = "time")]
Vec<sqlx::postgres::types::PgRange<sqlx::types::time::OffsetDateTime>> |
&[sqlx::postgres::types::PgRange<sqlx::types::time::OffsetDateTime>],

// Full text search
sqlx::postgres::types::TsVector,
Vec<sqlx::postgres::types::TsVector> | &[sqlx::postgres::types::TsVector],
},
ParamChecking::Strong,
feature-types: info => info.__type_feature_gate(),
Expand Down
18 changes: 18 additions & 0 deletions sqlx-postgres/src/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub enum PgType {
RecordArray,
Uuid,
UuidArray,
TsVector,
TsVectorArray,
Jsonb,
JsonbArray,
Int4Range,
Expand Down Expand Up @@ -333,6 +335,8 @@ impl PgType {
2287 => PgType::RecordArray,
2950 => PgType::Uuid,
2951 => PgType::UuidArray,
3614 => PgType::TsVector,
3643 => PgType::TsVectorArray,
3802 => PgType::Jsonb,
3807 => PgType::JsonbArray,
3904 => PgType::Int4Range,
Expand Down Expand Up @@ -441,6 +445,8 @@ impl PgType {
PgType::RecordArray => Oid(2287),
PgType::Uuid => Oid(2950),
PgType::UuidArray => Oid(2951),
PgType::TsVector => Oid(3614),
PgType::TsVectorArray => Oid(3643),
PgType::Jsonb => Oid(3802),
PgType::JsonbArray => Oid(3807),
PgType::Int4Range => Oid(3904),
Expand Down Expand Up @@ -542,6 +548,8 @@ impl PgType {
PgType::RecordArray => "RECORD[]",
PgType::Uuid => "UUID",
PgType::UuidArray => "UUID[]",
PgType::TsVector => "TSVECTOR",
PgType::TsVectorArray => "TSVECTOR[]",
PgType::Jsonb => "JSONB",
PgType::JsonbArray => "JSONB[]",
PgType::Int4Range => "INT4RANGE",
Expand Down Expand Up @@ -642,6 +650,8 @@ impl PgType {
PgType::RecordArray => "_record",
PgType::Uuid => "uuid",
PgType::UuidArray => "_uuid",
PgType::TsVector => "tsvector",
PgType::TsVectorArray => "_tsvector",
PgType::Jsonb => "jsonb",
PgType::JsonbArray => "_jsonb",
PgType::Int4Range => "int4range",
Expand Down Expand Up @@ -742,6 +752,8 @@ impl PgType {
PgType::RecordArray => &PgTypeKind::Array(PgTypeInfo(PgType::Record)),
PgType::Uuid => &PgTypeKind::Simple,
PgType::UuidArray => &PgTypeKind::Array(PgTypeInfo(PgType::Uuid)),
PgType::TsVector => &PgTypeKind::Simple,
PgType::TsVectorArray => &PgTypeKind::Array(PgTypeInfo(PgType::TsVector)),
PgType::Jsonb => &PgTypeKind::Simple,
PgType::JsonbArray => &PgTypeKind::Array(PgTypeInfo(PgType::Jsonb)),
PgType::Int4Range => &PgTypeKind::Range(PgTypeInfo::INT4),
Expand Down Expand Up @@ -855,6 +867,8 @@ impl PgType {
PgType::RecordArray => Some(Cow::Owned(PgTypeInfo(PgType::Record))),
PgType::Uuid => None,
PgType::UuidArray => Some(Cow::Owned(PgTypeInfo(PgType::Uuid))),
PgType::TsVector => None,
PgType::TsVectorArray => Some(Cow::Owned(PgTypeInfo(PgType::TsVector))),
PgType::Jsonb => None,
PgType::JsonbArray => Some(Cow::Owned(PgTypeInfo(PgType::Jsonb))),
PgType::Int4Range => None,
Expand Down Expand Up @@ -928,6 +942,10 @@ impl PgTypeInfo {
pub(crate) const UUID: Self = Self(PgType::Uuid);
pub(crate) const UUID_ARRAY: Self = Self(PgType::UuidArray);

// tsvector
pub(crate) const TS_VECTOR: Self = Self(PgType::TsVector);
pub(crate) const TS_VECTOR_ARRAY: Self = Self(PgType::TsVectorArray);

// record
pub(crate) const RECORD: Self = Self(PgType::Record);
pub(crate) const RECORD_ARRAY: Self = Self(PgType::RecordArray);
Expand Down
4 changes: 4 additions & 0 deletions sqlx-postgres/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ mod mac_address;
#[cfg(feature = "bit-vec")]
mod bit_vec;

mod ts_vector;
Copy link
Collaborator

@abonander abonander Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Lexeme and LexemeMeta are meant to be visible, this needs to be pub so their documentation gets rendered (I wouldn't reexport them here since it would be out of context).


pub use array::PgHasArrayType;
pub use citext::PgCiText;
pub use interval::PgInterval;
Expand All @@ -251,6 +253,8 @@ pub use range::PgRange;
#[cfg(any(feature = "chrono", feature = "time"))]
pub use time_tz::PgTimeTz;

pub use ts_vector::TsVector;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A listing should also be added to the table at line 23 above.


// used in derive(Type) for `struct`
// but the interface is not considered part of the public API
#[doc(hidden)]
Expand Down
Loading