Skip to content

Commit

Permalink
update to pgx 0.6.1; update dependencies; (fixes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefbarn committed Dec 16, 2022
1 parent 3d0e2d7 commit db2f1dd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[package]
name = "pgx_json_schema"
version = "0.2.2"
version = "0.3.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[features]
default = ["pg14"]
pg10 = ["pgx/pg10"]
pg11 = ["pgx/pg11"]
pg12 = ["pgx/pg12"]
pg13 = ["pgx/pg13"]
pg14 = ["pgx/pg14"]
pg15 = ["pgx/pg15"]
pg_test = []

[dependencies]
pgx = "0.4.0"
pgx-macros = "0.4.0"
pgx = "0.6.1"
pgx-macros = "0.6.1"
serde_json = "1.0.79"
jsonschema = {version = "0.16.0", default-features = false, features = []}
jsonschema = {version = "0.16.1", default-features = false, features = ["draft201909", "draft202012"]}
jtd = "0.3.1"
avro-rs = "0.13.0"

[dev-dependencies]
pgx-tests = "0.4.0"
pgx-tests = "0.6.1"

[profile.dev]
panic = "unwind"
Expand Down
3 changes: 2 additions & 1 deletion src/avro.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use avro_rs::types::Record;
use avro_rs::{Schema, Writer};
use pgx::*;
use pgx::prelude::*;
use pgx::JsonB;

#[pg_extern]
fn avro_is_valid(schema: JsonB, instance: JsonB) -> bool {
Expand Down
10 changes: 6 additions & 4 deletions src/json_schema.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use jsonschema::JSONSchema;
use pgx::*;
use pgx::prelude::*;
use pgx::JsonB;

#[pg_extern]
fn json_schema_is_valid(schema: JsonB, instance: JsonB) -> bool {
Expand All @@ -10,8 +11,9 @@ fn json_schema_is_valid(schema: JsonB, instance: JsonB) -> bool {
fn json_schema_get_errors(
schema: JsonB,
instance: JsonB,
) -> impl std::iter::Iterator<
Item = (
) -> TableIterator<
'static,
(
name!(error_value, JsonB),
name!(description, String),
name!(details, String),
Expand Down Expand Up @@ -41,7 +43,7 @@ fn json_schema_get_errors(
})
.collect();

new.into_iter()
TableIterator::new(new.into_iter())
}

#[cfg(any(test, feature = "pg_test"))]
Expand Down
7 changes: 4 additions & 3 deletions src/json_type_def.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use jtd::Schema;
use pgx::*;
use pgx::prelude::*;
use pgx::JsonB;

#[pg_extern]
fn jtd_is_valid(schema: JsonB, instance: JsonB) -> bool {
Expand All @@ -14,7 +15,7 @@ fn jtd_is_valid(schema: JsonB, instance: JsonB) -> bool {
fn jtd_get_errors(
schema: JsonB,
instance: JsonB,
) -> impl std::iter::Iterator<Item = (name!(instance_path, String), name!(schema_path, String))> {
) -> TableIterator<'static, (name!(instance_path, String), name!(schema_path, String))> {
let parsed_schema =
Schema::from_serde_schema(serde_json::from_value(schema.0).unwrap()).unwrap();
let result = jtd::validate(&parsed_schema, &instance.0, Default::default()).unwrap();
Expand All @@ -38,7 +39,7 @@ fn jtd_get_errors(
})
.collect();

new.into_iter()
TableIterator::new(new.into_iter())
}

#[cfg(any(test, feature = "pg_test"))]
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ mod avro;
mod json_schema;
mod json_type_def;

use pgx::*;

pg_module_magic!();
pgx::pg_module_magic!();

#[cfg(test)]
pub mod pg_test {
Expand Down

1 comment on commit db2f1dd

@dvv
Copy link

@dvv dvv commented on db2f1dd Dec 18, 2022

Choose a reason for hiding this comment

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

Thanks!

Please sign in to comment.