Skip to content

Commit

Permalink
Use double precision for float representation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonoPrest committed Oct 30, 2024
1 parent 7060a46 commit f6c2871
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codegenerator/cli/src/config_parsing/entity_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ impl GqlScalar {
}
"Timestamp" => GqlScalar::Timestamp,
"Bytes" => GqlScalar::Bytes,
_name => GqlScalar::Custom(name.to_string()),
name => GqlScalar::Custom(name.to_string()),
}
}

Expand All @@ -1403,7 +1403,7 @@ impl GqlScalar {
GqlScalar::ID => PGPrimitive::Text,
GqlScalar::String => PGPrimitive::Text,
GqlScalar::Int => PGPrimitive::Integer,
GqlScalar::Float => PGPrimitive::Numeric(None), // Should we allow this type? Rounding issues will abound.
GqlScalar::Float => PGPrimitive::DoublePrecision, // Should we allow this type? Rounding issues will abound.
GqlScalar::Boolean => PGPrimitive::Boolean,
GqlScalar::Bytes => PGPrimitive::Text,
GqlScalar::BigInt(None) => PGPrimitive::Numeric(None),
Expand Down
2 changes: 2 additions & 0 deletions codegenerator/cli/src/config_parsing/postgres_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum Primitive {
Text,
Integer,
Numeric(Option<(u32, u32)>), // (precision, scale)
DoublePrecision,
Serial,
Json,
Timestamp,
Expand All @@ -27,6 +28,7 @@ impl Primitive {
Self::Serial => "Serial".to_string(),
Self::Json => "Json".to_string(),
Self::Timestamp => "Timestamp".to_string(),
Self::DoublePrecision => "DoublePrecision".to_string(),
Self::Enum(enum_name) => format!("Custom(Enums.{enum_name}.enum.name)"),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type fieldType =
| @as("INTEGER") Integer
| @as("BOOLEAN") Boolean
| @as("NUMERIC") Numeric
| @as("DOUBLE PRECISION") DoublePrecision
| @as("TEXT") Text
| @as("SERIAL") Serial
| @as("JSONB") JsonB
Expand Down

0 comments on commit f6c2871

Please sign in to comment.