Skip to content

Commit

Permalink
transformer: uro:id などのnamespaceを削除しない (#441)
Browse files Browse the repository at this point in the history
close #438 

## 備考

~(ただし、このPRだけでは、これが発覚した #398 (luseなどのデータ &
Gpkgでのエラー)は完全解消しない。また別途、問題がある)~ → 問題ない、
b31273b
で修正された

` cargo run --
~/Desktop/plateau/13100_tokyo23-ku_2022_citygml_1_2_op/udx/luse/* --sink
gpkg --output ~/Desktop/tmp.gpkg`

### このPR以前

```
> Feedback message from the pipeline FeedbackMessage {
  message: "Fatal error", error: Some(Other("SQLx error: error returned from database: (code: 1) duplicate column name: id"))
}
```

~~### このPR以後~~

```
> Feedback message from the pipeline FeedbackMessage {
  message: "Fatal error", error: Some(Other("SQLx error: error returned from database: (code: 1) table luse:LandUse has no column named creationDate, genericAttribute"))
}
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **バグ修正**
	- 特殊文字を正しく処理するために、SQLクエリの列名にダブルクォートを追加しました。

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
sorami authored Mar 8, 2024
1 parent 6e41959 commit 4e006df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nusamai-gpkg/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'c> GpkgTransaction<'c> {
query_string.push_str("id INTEGER NOT NULL PRIMARY KEY");
}
table_info.columns.iter().for_each(|column| {
query_string.push_str(&format!(", {} {}", column.name, column.data_type));
query_string.push_str(&format!(", \"{}\" {}", column.name, column.data_type));
});
query_string.push_str(");");
sqlx::query(&query_string).execute(&mut *executor).await?;
Expand Down Expand Up @@ -259,7 +259,7 @@ impl<'c> GpkgTransaction<'c> {
table_name,
attributes
.keys()
.map(|key| key.to_string())
.map(|key| format!("\"{}\"", key))
.collect::<Vec<_>>()
.join(", "),
vec!["?"; attributes.len()].join(", ")
Expand Down
13 changes: 10 additions & 3 deletions nusamai/src/transformer/transform/attrname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,18 @@ impl EditFieldNamesTransform {

name.find(':').map(|pos| {
let key = &name[pos + 1..]; // remove the namespace prefix

if let Some(new_key) = self.general_rename_map.get(key) {
new_key.as_ref()
} else {
key
return new_key.as_ref();
}

// If the namespace is removed, it will conflict with the global "id" column (= "gml:id").
// Therefore, don't remove the namespace prefix
if key == "id" {
return name;
}

key
})
}

Expand Down

0 comments on commit 4e006df

Please sign in to comment.