Skip to content

Commit 5306111

Browse files
committed
update readme to note the change in de-duplication behavior
1 parent 0553cf8 commit 5306111

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ go get -u github.com/hackafterdark/carta
236236

237237
## Important Notes
238238

239-
Carta removes any duplicate rows. This is a side effect of the data mapping as it is unclear which object to instantiate if the same data arrives more than once.
240-
If this is not a desired outcome, you should include a uniquely identifiable columns in your query and the corresponding fields in your structs.
239+
When mapping to **slices of structs**, Carta removes duplicate entities. This is a side effect of the data mapping process, which merges rows that identify the same entity (e.g., a `Blog` with the same ID appearing in multiple rows due to a `JOIN`). To ensure correct mapping, you should always include uniquely identifiable columns (like a primary key) in your query for each struct entity.
240+
241+
When mapping to **slices of basic types** (e.g., `[]string`, `[]int`), every row from the query is treated as a unique element, and **no de-duplication occurs**.
241242

242243
To prevent relatively expensive reflect operations, carta caches the structure of your struct using the column mames of your query response as well as the type of your struct.
243244

0 commit comments

Comments
 (0)