Skip to content

Commit

Permalink
Enh/only forbid uppercase ascii (#3416)
Browse files Browse the repository at this point in the history
* enh(tables): allow symbols and numbers in col names

* delete table if rows upsert fails

---------

Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Jan 24, 2024
1 parent 98eeaab commit 803e85b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/databases/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ impl Table {
None => Err(anyhow!("Row {} is not an object", row_index,))?,
};
match object.keys().find(|key| match key.chars().next() {
Some(c) => !c.is_ascii_lowercase(),
Some(c) => c.is_ascii_uppercase(),
None => false,
}) {
Some(key) => Err(anyhow!(
"Row {} has a key '{}' that is not lowercase",
"Row {} has a key '{}' that contains uppercase characters",
row_index,
key
))?,
Expand Down
19 changes: 19 additions & 0 deletions front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ async function handler(
"Failed to upsert rows."
);

const delRes = await coreAPI.deleteTable({
projectId: dataSource.dustAPIProjectId,
dataSourceName: dataSource.name,
tableId,
});

if (delRes.isErr()) {
logger.error(
{
dataSourceName: dataSource.name,
workspaceId: owner.id,
tableId,
tableName: name,
error: delRes.error,
},
"Failed to delete table after failed upsert."
);
}

return apiError(req, res, {
status_code: 500,
api_error: {
Expand Down

0 comments on commit 803e85b

Please sign in to comment.