Comments (4)
The tests are set up with an allowed dependencies file here:
plrust/plrust-tests/src/lib.rs
Lines 71 to 77 in 3725747
from plrust.
That's weird.
from plrust.
I created a test in plrust-tests/src/dependencies.rs
that I wanted to use to reproduce the issue.
Though I did get:
0: `faker_rand` is not an allowed dependency
New Test:
#[pg_test]
#[cfg(not(feature = "sandboxed"))]
#[search_path(@extschema@)]
fn plrust_deps_docs() -> spi::Result<()> {
let definition = r#"
CREATE OR REPLACE FUNCTION plrust.random_company_name(locale TEXT)
RETURNS TEXT
LANGUAGE plrust STRICT
AS $$
[dependencies]
faker_rand = "0.1"
rand = "0.8"
[code]
match locale {
"en_us" => {
use faker_rand::en_us::company::CompanyName;
Ok(Some(rand::random::<CompanyName>().to_string()))
}
"fr_fr" => {
use faker_rand::fr_fr::company::CompanyName;
Ok(Some(rand::random::<CompanyName>().to_string()))
}
_ => panic!("Unsupported locale. Use en_us or fr_fr")
}
$$;
"#;
Spi::run(definition)?;
let retval = Spi::get_one::<String>(
r#"
SELECT plrust.random_company_name('fr_fr') AS fr_fr;
"#
);
assert!(retval.is_ok());
assert!(retval.unwrap().is_some());
Ok(())
}
Full Error:
Client Error:
0: `faker_rand` is not an allowed dependency
Location:
plrust/src/user_crate/mod.rs:351
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
0: plrust::user_crate::parse_source_and_deps
at plrust/src/user_crate/mod.rs:308
1: plrust::user_crate::crating::try_from_fn_oid with db_oid=Oid(16384) fn_oid=Oid(16481)
at plrust/src/user_crate/crating.rs:59
2: plrust::user_crate::try_from_fn_oid
at plrust/src/user_crate/mod.rs:103
3: plrust::plrust::compile_function with fn_oid=Oid(16481)
at plrust/src/plrust.rs:100
4: plrust::plrust_validator with fn_oid=Oid(16481) fcinfo=0x7fffe3ab9cd0
at plrust/src/lib.rs:225
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
postgres location: lib.rs
rust location: SQL statement "
CREATE OR REPLACE FUNCTION plrust.random_company_name(locale TEXT)
RETURNS TEXT
LANGUAGE plrust STRICT
AS $$
[dependencies]
faker_rand = "0.1"
rand = "0.8"
[code]
match locale {
"en_us" => {
use faker_rand::en_us::company::CompanyName;
Ok(Some(rand::random::<CompanyName>().to_string()))
}
"fr_fr" => {
use faker_rand::fr_fr::company::CompanyName;
Ok(Some(rand::random::<CompanyName>().to_string()))
}
_ => panic!("Unsupported locale. Use en_us or fr_fr")
}
$$;
"
', /home/david/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-tests-0.10.0/src/framework.rs:172:9
failures:
dependencies::tests::pg_plrust_deps_docs
test result: FAILED. 48 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 268.83s
Is this related to trusted / untrusted mode?
from plrust.
Thanks. Interesting that the test still passes.
So I changed
assert!(retval.is_ok());
assert!(retval.unwrap().is_some());
To
assert_eq!(retval, Ok(Some("Is this a random french company name.".to_string())));
And now I get:
Client Error:
assertion failed: `(left == right)`
left: `Ok(Some("Agathange EI"))`,
right: `Ok(Some("Is this a random french company name."))`
postgres location: dependencies.rs
So this means that this example does work in the unit tests. Just not when I launch using Dockerfile.try
from plrust.
Related Issues (20)
- Call a function from another function HOT 6
- Add a function to list all the allowlisted crates with their respective versions, features HOT 2
- Plrustc will not compile on alpine/postgres. HOT 3
- Compiling multiple functions together HOT 7
- fix `plrust/build` to dynamically determine pgrx version HOT 1
- Support for custom (opaque) type HOT 5
- plrustc does not seem to catch `include!` macro properly HOT 3
- env/option_env failing to be linted by plrustc HOT 7
- Accessing JsonbContainer HOT 12
- UDF load time is high when compared to PL/PGSQL HOT 2
- How to return an array of any dimenion from pl/rust function.
- Enhancement to prevent cargo from recompiling allowlisted dependencies. HOT 7
- plrust installation fails when postgres 15 compiled with gprof profiler HOT 2
- Publish to https://database.dev/ HOT 9
- enumerated type as function arg? HOT 7
- JSonb extract slower in Pl/Rust than in Pl/PgSql HOT 3
- Postgres Triggers, achieve different behaviour on INSERT, UPDATE, etc.
- Problem with clap v4.5.4 HOT 5
- seg faults when working with composite types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plrust.