Update to array records with new v3 `setColumn` query
See original GitHub issueI’m looking to add a new value to a column value of uuid[]
and I’m running into scoping issues. I’m not able to get the current values of that column when trying to add a new value to it. This stems from the add to LINQ style column update from #40. I’d be happy to update the documentation like discussed in #50 and this use case as well when this is figured out. I wasn’t really able to find any complex updates from other user searching the internet with the new syntax.
CREATE TABLE Users (
id uuid NOT NULL PRIMARY KEY,
items uuid[] NOT NULL DEFUALT ARRAY[]::uuid[] )
type User =
{ Id: Guid
Items: Guid list }
let userTable = table<User>
let addItem (conn: IDbConnection) (userId: Guid) (itemId: Guid) =
update {
for u in userTable do
setColumn u.Items (List.Cons(itemId, u.Items)
where (id = userId)
}
error FS0039: The value or constructor 'u' is not defined
The equivalent SQL command I’m trying to emulate is
UPDATE users
SET items = array_append(items, @item)
WHERE id = @id
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Updating a value in an ARRAY in a BigQuery table
Try this: UPDATE itemInformation SET itemDelta = ARRAY(SELECT AS STRUCT * REPLACE(9426 AS typeId) FROM UNNEST(itemDelta)) WHERE 2424 IN ...
Read more >SQL Update Statement — Example Queries for ...
The UPDATE statement can be used to update a single column, a larger set of records (through the use of conditions), and/or the...
Read more >How to Modify Arrays in PostgreSQL
The most basic way to modify an array column are to overwrite all values by assigning it a new array, or to specify...
Read more >How to Update millions or records in a table - Ask TOM
I got a table which contains millions or records. I want to update and commit every time for so many records ( say...
Read more >How to update an array field for many records at one time?
Definitely better option how to update all these records is to use the background script (module "Scripts - Background"). So I think you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it might be as easy as this:
open Dapper
is key here because Dapper adds its own extension methods (likeExecute
) on top of the connection.I haven’t done it with the old version. I just started to pick up this library recently using v3. If this wasn’t a feature that was supported before then I guess this isn’t actually an issue but a new use case