Skip to content

Commit

Permalink
Merge pull request #16 from pksunkara/fixes-13
Browse files Browse the repository at this point in the history
Add commutator
  • Loading branch information
pksunkara authored Aug 23, 2023
2 parents eb8e9cf + a72c732 commit 75678e3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
# Ensure installed pg_config is first on path
export PATH=$PATH:/usr/lib/postgresql/${{ matrix.postgres }}/bin
cargo install cargo-pgrx --version 0.9.7 --locked
cargo install cargo-pgrx --version 0.10.0-beta.4 --locked
cargo pgrx init --pg${{ matrix.postgres }}=/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config
- name: Build artifacts
run: |
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pg_test = []

[dependencies]
inner_ulid = { package = "ulid", version = "1.0.0" }
pgrx = "=0.9.7"
pgrx = "=0.10.0-beta.4"

[dev-dependencies]
pgrx-tests = "=0.9.7"
pgrx-tests = "=0.10.0-beta.4"

[profile.dev]
panic = "unwind"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN \
cargo --version

# pgrx
RUN cargo install cargo-pgrx --version 0.9.7 --locked
RUN cargo install cargo-pgrx --version 0.10.0-beta.4 --locked

RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config)

Expand Down
46 changes: 45 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pub extern "C" fn _PG_init() {
}

#[allow(non_camel_case_types)]
#[derive(PostgresType, PostgresEq, PostgresHash, PostgresOrd, Debug, PartialEq, PartialOrd, Eq, Hash, Ord)]
#[derive(
PostgresType, PostgresEq, PostgresHash, PostgresOrd, Debug, PartialEq, PartialOrd, Eq, Hash, Ord,
)]
#[inoutfuncs]
pub struct ulid(u128);

Expand Down Expand Up @@ -194,6 +196,48 @@ mod tests {
let result = Spi::get_one::<ulid>("SELECT gen_ulid();").unwrap();
assert!(result.is_some());
}

#[pg_test]
fn test_hash() {
Spi::run(
"CREATE TABLE foo (
id ulid,
data TEXT
);
CREATE TABLE bar (
id ulid,
foo_id ulid
);
INSERT INTO foo DEFAULT VALUES;
INSERT INTO bar DEFAULT VALUES;
SELECT *
FROM bar
JOIN foo ON bar.id = foo.id;",
)
.unwrap();
}

#[pg_test]
fn test_commutator() {
Spi::run(
"CREATE TABLE foo (
id ulid,
data TEXT
);
CREATE TABLE bar (
id ulid
);
SELECT *
FROM bar
JOIN foo ON bar.id = foo.id;",
)
.unwrap();
}
}

/// This module is required by `cargo pgrx test` invocations.
Expand Down

0 comments on commit 75678e3

Please sign in to comment.