Skip to content

Commit 13025df

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/native-reference-errors
# Conflicts: # tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py
2 parents d407fe4 + 19ae79e commit 13025df

84 files changed

Lines changed: 3452 additions & 1456 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.release-please-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.143.1"
2+
".": "0.144.0"
33
}

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [0.144.0](https://github.com/chio-labs/sqlbuild/compare/v0.143.1...v0.144.0) (2026-10-08)
4+
5+
6+
### Features
7+
8+
* **native:** build model config and validate models natively behind the preview engine ([#1034](https://github.com/chio-labs/sqlbuild/issues/1034)) ([24e47aa](https://github.com/chio-labs/sqlbuild/commit/24e47aa5399b702a92e2fbc13aac70cf39f8d15a))
9+
* **native:** report attachment errors natively ([#1038](https://github.com/chio-labs/sqlbuild/issues/1038)) ([ee19894](https://github.com/chio-labs/sqlbuild/commit/ee19894bb5328fcb3310e21eff3962934189fb48))
10+
* **native:** report declaration and scope errors natively ([#1033](https://github.com/chio-labs/sqlbuild/issues/1033)) ([241fb56](https://github.com/chio-labs/sqlbuild/commit/241fb56ef8454c7e9c5739cbb3169d4b5e2a0fd1))
11+
312
## [0.143.1](https://github.com/chio-labs/sqlbuild/compare/v0.143.0...v0.143.1) (2026-10-08)
413

514

‎Cargo.lock‎

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ python-boundary = "sqlbuild-python"
3737
polyglot-floor = "sqlbuild-analysis"
3838

3939
[workspace.package]
40-
version = "0.143.1"
40+
version = "0.144.0"
4141
edition = "2024"
4242
license = "Apache-2.0"
4343
publish = false
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//! The first config field, in Python's walk order, whose string holds a macro call.
2+
3+
use crate::config_presence::_helpers::macro_calls::macro_call;
4+
use crate::config_presence::models::{MacroPath, Presence};
5+
use crate::types::{AuthoredNode, NodeKind};
6+
7+
/// Walk config values as `validate_no_macros_in_config_value` does, skipping the `skipped` keys.
8+
pub fn first_macro_path<N: AuthoredNode>(values: &N, skipped: &[&str]) -> MacroPath {
9+
let mut entries = values.entries();
10+
entries.retain(|(key, _)| !skipped.iter().any(|name| key.is_text(name)));
11+
walk_entries(&entries, &[])
12+
}
13+
14+
fn walk<N: AuthoredNode>(node: &N, path: &[String]) -> MacroPath {
15+
match node.kind() {
16+
NodeKind::Str => match node.with_text(macro_call) {
17+
Some(Presence::Present) => MacroPath::Found(path.to_vec()),
18+
Some(Presence::Absent) => MacroPath::Absent,
19+
Some(Presence::Deferred) | None => MacroPath::Deferred,
20+
},
21+
NodeKind::Map => walk_entries(&node.entries(), path),
22+
NodeKind::List | NodeKind::Tuple => {
23+
for item in node.items() {
24+
let found = walk(&item, path);
25+
if found != MacroPath::Absent {
26+
return found;
27+
}
28+
}
29+
MacroPath::Absent
30+
}
31+
_ => MacroPath::Absent,
32+
}
33+
}
34+
35+
fn walk_entries<N: AuthoredNode>(entries: &[(N, N)], path: &[String]) -> MacroPath {
36+
for (key, value) in entries {
37+
if key.kind() != NodeKind::Str {
38+
continue;
39+
}
40+
let Some(name) = key.text() else {
41+
return MacroPath::Deferred;
42+
};
43+
let mut child: Vec<String> = path.to_vec();
44+
child.push(name);
45+
let found = walk(value, &child);
46+
if found != MacroPath::Absent {
47+
return found;
48+
}
49+
}
50+
MacroPath::Absent
51+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod contains_macro_call;
22
pub mod contains_template;
3+
pub mod first_macro_path;

‎crates/sqlbuild-model-config/src/config_presence/models.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ pub enum Presence {
88
/// A string needs Python's Unicode `\s` class to decide.
99
Deferred,
1010
}
11+
12+
/// Where Python's config walk first finds a macro call.
13+
#[derive(Clone, Debug, PartialEq, Eq)]
14+
pub enum MacroPath {
15+
/// The mapping keys leading to the first string holding a macro call.
16+
Found(Vec<String>),
17+
Absent,
18+
/// A string before any match needs Python's Unicode rules to decide.
19+
Deferred,
20+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//! Errors the native config stages report exactly as the Python stages raise them.
2+
3+
/// The Python exception class one error raises.
4+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5+
pub enum ErrorClass {
6+
/// `CompileInputError`.
7+
CompileInput,
8+
/// `ConfigValueTypeError` for a config key that must hold a string.
9+
ConfigValueType,
10+
/// `ResourceIdentityError` for an identity that is not canonical snake_case.
11+
ResourceIdentity,
12+
/// `DiscoveryConflictError` for equally specific path-default keys.
13+
DiscoveryConflict,
14+
}
15+
16+
/// One error with the class, message, code and help the Python stage raises.
17+
#[derive(Clone, Debug, PartialEq, Eq)]
18+
pub struct ConfigError {
19+
pub class: ErrorClass,
20+
/// The message; empty for `ConfigValueTypeError`, which Python words from the value's type.
21+
pub message: String,
22+
/// The diagnostic code when it is not the class default.
23+
pub code: Option<&'static str>,
24+
pub help: Option<String>,
25+
/// The config key a `ConfigValueTypeError` names.
26+
pub key: Option<String>,
27+
}
28+
29+
impl ConfigError {
30+
/// A `CompileInputError` with this message.
31+
pub fn compile(message: String) -> Self {
32+
Self {
33+
class: ErrorClass::CompileInput,
34+
message,
35+
code: None,
36+
help: None,
37+
key: None,
38+
}
39+
}
40+
41+
/// The `ConfigValueTypeError` `get_config_str` raises for a non-string `key`.
42+
pub fn config_value_type(key: &str) -> Self {
43+
Self {
44+
class: ErrorClass::ConfigValueType,
45+
message: String::new(),
46+
code: None,
47+
help: None,
48+
key: Some(key.to_owned()),
49+
}
50+
}
51+
52+
/// This error of another class.
53+
pub fn with_class(mut self, class: ErrorClass) -> Self {
54+
self.class = class;
55+
self
56+
}
57+
58+
/// This error with help text.
59+
pub fn with_help(mut self, help: impl Into<String>) -> Self {
60+
self.help = Some(help.into());
61+
self
62+
}
63+
64+
/// This error with a diagnostic code.
65+
pub fn with_code(mut self, code: &'static str) -> Self {
66+
self.code = Some(code);
67+
self
68+
}
69+
}

0 commit comments

Comments
 (0)