forked from paradedb/paradedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: segfault with fields of type '::json' (paradedb#1654)
- Loading branch information
1 parent
3271969
commit 4cc5a21
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2023-2024 Retake, Inc. | ||
// | ||
// This file is part of ParadeDB - Postgres for Search and Analytics | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
mod fixtures; | ||
|
||
use fixtures::*; | ||
use rstest::*; | ||
use sqlx::PgConnection; | ||
|
||
// In addition to checking whether all the expected types work for keys, make sure to include tests for anything that | ||
// is reliant on keys (e.g. stable_sort, alias) | ||
|
||
#[rstest] | ||
fn json_datatype(mut conn: PgConnection) { | ||
r#" | ||
CREATE TABLE test_table ( | ||
id serial8, | ||
value json | ||
); | ||
INSERT INTO test_table (value) VALUES ('{"currency_code": "USD", "salary": 120000 }'); | ||
INSERT INTO test_table (value) VALUES ('{"currency_code": "USD", "salary": 75000 }'); | ||
INSERT INTO test_table (value) VALUES ('{"currency_code": "USD", "salary": 140000 }'); | ||
"# | ||
.execute(&mut conn); | ||
|
||
// if we don't segfault postgres here, we're good | ||
r#" | ||
CALL paradedb.create_bm25( | ||
table_name => 'test_table', | ||
index_name => 'test_index', | ||
key_field => 'id', | ||
json_fields => paradedb.field('value', indexed => true, fast => true) | ||
); | ||
"# | ||
.execute(&mut conn); | ||
} |