-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes issue #1301 such that the schema generator now schema-qualifies the operator name when generating a `CREATE OPERATOR` statement. It also qualifies the associated function. This allows us to pick up the fact that a `#[pg_operator]` annotation was applied to function in a module with `#[pg_schema]`.
- Loading branch information
1 parent
ef033db
commit bc45e55
Showing
3 changed files
with
44 additions
and
2 deletions.
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
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,35 @@ | ||
//LICENSE Portions Copyright 2019-2021 ZomboDB, LLC. | ||
//LICENSE | ||
//LICENSE Portions Copyright 2021-2023 Technology Concepts & Design, Inc. | ||
//LICENSE | ||
//LICENSE Portions Copyright 2023-2023 PgCentral Foundation, Inc. <contact@pgcentral.org> | ||
//LICENSE | ||
//LICENSE All rights reserved. | ||
//LICENSE | ||
//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
use pgrx::prelude::*; | ||
|
||
#[pg_schema] | ||
mod pg_catalog { | ||
use pgrx::{opname, pg_operator}; | ||
|
||
#[pg_operator] | ||
#[opname(==>)] | ||
fn concat_strings(left: String, right: String) -> String { | ||
left + &right | ||
} | ||
} | ||
|
||
#[cfg(any(test, feature = "pg_test"))] | ||
#[pg_schema] | ||
mod tests { | ||
#[allow(unused_imports)] | ||
use crate as pgrx_tests; | ||
use pgrx::prelude::*; | ||
|
||
#[pg_test] | ||
fn test_correct_schema() { | ||
let result = Spi::get_one::<String>("SELECT 'hello, ' OPERATOR(pg_catalog.==>) 'world';"); | ||
assert_eq!(result, Ok(Some(String::from("hello, world")))); | ||
} | ||
} |