Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-stytch committed Sep 19, 2024
1 parent 1bb6410 commit 213644f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/src/schema/content/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher};

use super::Categorical;

use crate::graph::number::{RandomF32, RandomI8, RandomI16, RandomI32, RandomU32};
use crate::graph::number::{RandomF32, RandomI16, RandomI32, RandomI8, RandomU32};
use serde::{ser::Serializer, Serialize};

#[derive(Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion core/src/schema/inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::{
Content, DateTimeContent, Id, NumberContent, NumberKindExt, ObjectContent, OneOfContent,
RangeStep, StringContent, ValueKindExt,
};
use crate::graph::prelude::content::number_content::{I8, I16, I32, I64};
use crate::graph::prelude::content::number_content::{I16, I32, I64, I8};
use crate::schema::UniqueContent;
use num::Zero;

Expand Down
19 changes: 7 additions & 12 deletions synth/src/datasource/mysql_datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rust_decimal::Decimal;
use sqlx::mysql::{MySqlColumn, MySqlPoolOptions, MySqlRow};
use sqlx::{Column, MySql, Pool, Row, TypeInfo};
use std::collections::BTreeMap;
use synth_core::schema::number_content::{F64, I8, I16, I32, I64, U64};
use synth_core::schema::number_content::{F64, I16, I32, I64, I8, U64};
use synth_core::schema::{
ChronoValueType, DateTimeContent, NumberContent, RangeStep, RegexContent, StringContent,
};
Expand Down Expand Up @@ -88,7 +88,8 @@ impl SqlxDataSource for MySqlDataSource {

fn decode_to_content(&self, column_info: &ColumnInfo) -> Result<Content> {
let content = match column_info.data_type.to_lowercase().as_str() {
"char" | "varchar" | "text" | "binary" | "varbinary" | "enum" | "set" | "mediumtext" | "blob" => {
"char" | "varchar" | "text" | "binary" | "varbinary" | "enum" | "set"
| "mediumtext" | "blob" => {
let pattern = "[a-zA-Z0-9]{0, {}}".replace(
"{}",
&format!("{}", column_info.character_maximum_length.unwrap_or(1)),
Expand All @@ -97,18 +98,12 @@ impl SqlxDataSource for MySqlDataSource {
RegexContent::pattern(pattern).context("pattern will always compile")?,
))
}
"int" | "integer" | "mediumint" => {
"int" | "integer" | "mediumint" => {
Content::Number(NumberContent::I32(I32::Range(RangeStep::default())))
}
"tinyint" => {
Content::Number(NumberContent::I8(I8::Range(RangeStep::default())))
}
"smallint" => {
Content::Number(NumberContent::I16(I16::Range(RangeStep::default())))
}
"bigint" => {
Content::Number(NumberContent::I64(I64::Range(RangeStep::default())))
}
"tinyint" => Content::Number(NumberContent::I8(I8::Range(RangeStep::default()))),
"smallint" => Content::Number(NumberContent::I16(I16::Range(RangeStep::default()))),
"bigint" => Content::Number(NumberContent::I64(I64::Range(RangeStep::default()))),
"serial" => Content::Number(NumberContent::U64(U64::Range(RangeStep::default()))),
"float" | "double" | "numeric" | "decimal" => {
Content::Number(NumberContent::F64(F64::Range(RangeStep::default())))
Expand Down

0 comments on commit 213644f

Please sign in to comment.