added limit 1 to arrays treated as a single value in schemas

This commit is contained in:
2026-07-16 13:43:08 -04:00
parent 1fedf5253c
commit c4bf6bde58
47 changed files with 616 additions and 586 deletions

View File

@ -2,7 +2,7 @@ use crate::database::schema::Schema;
#[allow(unused_imports)]
use crate::drop::{Error, ErrorDetails};
#[allow(unused_imports)]
use std::collections::HashMap;
use indexmap::IndexMap;
use std::sync::Arc;
impl Schema {
@ -19,7 +19,7 @@ impl Schema {
if !c.is_ascii_lowercase() && !c.is_ascii_digit() && c != '_' && c != '.' && c != '$' {
errors.push(Error {
code: "INVALID_IDENTIFIER".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("character".to_string(), c.to_string()),
("field_name".to_string(), field_name.to_string()),
("identifier".to_string(), id.to_string()),

View File

@ -7,7 +7,6 @@ pub mod polymorphism;
use crate::database::schema::Schema;
use crate::drop::{Error, ErrorDetails};
use indexmap::IndexMap;
use std::collections::HashMap;
impl Schema {
pub fn compile(
@ -64,7 +63,7 @@ impl Schema {
if custom_type_count > 1 {
errors.push(Error {
code: "MULTIPLE_INHERITANCE_PROHIBITED".to_string(),
values: Some(HashMap::from([("types".to_string(), types.join(", "))])),
values: Some(IndexMap::from([("types".to_string(), types.join(", "))])),
details: ErrorDetails {
path: Some(path.clone()),
schema: Some(root_id.to_string()),

View File

@ -1,6 +1,6 @@
use crate::drop::{Error, ErrorDetails};
use indexmap::IndexSet;
use std::collections::HashMap;
use indexmap::IndexMap;
use crate::database::schema::Schema;
impl Schema {
@ -144,7 +144,7 @@ impl Schema {
if options.contains_key(&val) {
errors.push(Error {
code: "POLYMORPHIC_COLLISION".to_string(),
values: Some(HashMap::from([("value".to_string(), val.to_string())])),
values: Some(IndexMap::from([("value".to_string(), val.to_string())])),
details: ErrorDetails {
path: Some(path.to_string()),
schema: Some(root_id.to_string()),

View File

@ -1,6 +1,7 @@
use crate::drop::{Error, ErrorDetails};
use serde_json::Value;
use std::collections::{HashMap, HashSet};
use indexmap::IndexMap;
pub fn compose(val: &mut Value, errors: &mut Vec<Error>) {
let mut traits = HashMap::new();
@ -114,7 +115,7 @@ fn resolve_in_place(
if visited.contains(inc_name) {
errors.push(Error {
code: "CIRCULAR_INCLUDE_DETECTED".to_string(),
values: Some(HashMap::from([(
values: Some(IndexMap::from([(
"include".to_string(),
inc_name.to_string(),
)])),
@ -218,7 +219,7 @@ fn resolve_in_place(
} else {
errors.push(Error {
code: "TRAIT_NOT_FOUND".to_string(),
values: Some(HashMap::from([(
values: Some(IndexMap::from([(
"include".to_string(),
inc_name.to_string(),
)])),

View File

@ -28,7 +28,7 @@ use serde_json::Value;
use indexmap::IndexMap;
use std::sync::Arc;
use r#type::Type;
use std::collections::HashMap;
use crate::drop::{Drop, Error, ErrorDetails};
#[derive(serde::Serialize)]
@ -76,7 +76,7 @@ impl Database {
Err(e) => {
errors.push(Error {
code: "DATABASE_ENUM_PARSE_FAILED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("enum".to_string(), name.clone()),
("reason".to_string(), e.to_string()),
])),
@ -104,7 +104,7 @@ impl Database {
Err(e) => {
errors.push(Error {
code: "DATABASE_TYPE_PARSE_FAILED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("type".to_string(), name.clone()),
("reason".to_string(), e.to_string()),
])),
@ -136,7 +136,7 @@ impl Database {
Err(e) => {
errors.push(Error {
code: "DATABASE_RELATION_PARSE_FAILED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("relation".to_string(), constraint.clone()),
("reason".to_string(), e.to_string()),
])),
@ -164,7 +164,7 @@ impl Database {
Err(e) => {
errors.push(Error {
code: "DATABASE_PUNC_PARSE_FAILED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("punc".to_string(), name.clone()),
("reason".to_string(), e.to_string()),
])),
@ -461,7 +461,7 @@ impl Database {
errors.push(Error {
code: "EDGE_MISSING".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("parent_type".to_string(), parent_type.to_string()),
("child_type".to_string(), child_type.to_string()),
("property_name".to_string(), prop_name.to_string()),
@ -563,7 +563,7 @@ impl Database {
errors.push(Error {
code: "AMBIGUOUS_TYPE_RELATIONS".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("parent_type".to_string(), parent_type.to_string()),
("child_type".to_string(), child_type.to_string()),
("property_name".to_string(), prop_name.to_string()),