Questions tagged [upsert]

UPSERT is a combination of UPDATE and INSERT, typically used in relational databases.

UPSERT refers to types of statements (usually database statements) that INSERT an item (record) to a resource (table in a database) where, if the item already exists, it will update the existing item with the fields provided. The term UPSERT is an amalgamation of UPDATE and INSERT and is common slang among database developers.

1227 questions
0
votes
0 answers

Deciding to use insert or update depending if unique key is in table

So I have a table which will be keeping an average energy usage for specific stores at specific temperatures. Store + Temperature(Integer) is not in table -> Add to the table Store + Temperature is in table -> Use two of the rows parameters …
Eric G
  • 928
  • 1
  • 9
  • 29
0
votes
1 answer

Upsert removes field if it's not in the new document

Let's assume the following model (note strict:false): var Test = db.model('Test', { a: {type: String, required: true}, b: {type: String} }, {strict: false}); and I currently have this document in the database: { 'a': 'hello', 'b': 'world', …
Juicy
  • 11,840
  • 35
  • 123
  • 212
0
votes
1 answer

Issue on MongoDB bulk load with upsert method

I am trying to load the 8m[rows] * 1k[columns] python dataframe into Mongo. For the performance improvement I have planned to use Mongo bulk operation.There will be update also I have to do in the collections on daily basis so that I used the upsert…
0
votes
0 answers

mongo driver upsert: false creates new document

I am combining both mongomapper and mongo driver in my project. I had to downgrade version of mongo driver, cause mongomapper depends on 1.12.5. Unfortunately I've got problem with update({search_hash}, {update_hash}, upsert: false), because it will…
Robs
  • 153
  • 2
  • 10
0
votes
1 answer

Mongoid push with upsert

I've got model User: class User field :username, type: String embeds_many :products end class Product field :name, type: String embedded_in :user end I would like to have single operation that would: insert the user update the user in…
Jakub Troszok
  • 99,267
  • 11
  • 41
  • 53
0
votes
2 answers

Update a column of each and every newly inserted (same row) record on a table depends on another column value without Trigger and default constraint

I have a table with an identity column (say Column1) and an integer column Column2 (nullable) While inserting a row into this table, if the value passed to the Column2 is null, copy the Column1 value. If not null value is passed as argument for…
0
votes
1 answer

How to resolve a null match count on upsert filter?

I've added a method to a MongoDB database repository class, that is supposed to upsert/update documents. But I noticed after calling the UpdateCustomer() on a document, a new one is created and the old is unmodified. In short, the upsert method is…
Brian Var
  • 6,029
  • 25
  • 114
  • 212
0
votes
1 answer

Rethinkdb replace document if document exists, else insert document

I would like to insert a document if it doesn't exist (client_nr not found). If this exists, replace the whole document with new values. The only other this is, that the client_nr is not the primary key. The primary key is the default id created by…
Big Skinny
  • 53
  • 7
0
votes
2 answers

how to upsert with parent id in elastic4s

I'm using elastic4s to make index in ElasticSearch. My code as following: var seqBulkDef = SeqBulkCompatibleDefinition seqBulkDef=seqBulkDef:+request(sha256, parentId, indexMap, ES_INDEX, ES_INDEX_TYPE) val resp = client.execute (bulk…
Jack
  • 5,540
  • 13
  • 65
  • 113
0
votes
0 answers

How to write an upsert Cassandra CQL query using JSON?

It seems that Cassabdra behaves differently when inserting data to (existing row in) a table while not/using JSON. Here is an example: "INSERT INTO " + tableName + "(" + fields + ") VALUES (" + values + ")" "INSERT INTO " + tableName + " JSON '" +…
Eyal Weisz
  • 95
  • 1
  • 10
0
votes
1 answer

Upsert postgresql returning id

Initially I thought this was a heroku issue as, for some bizarre reason this code runs fine locally, but on further investigation I realized id was returning 0 all the time. Essentially I am trying to code an upsert that returns the id. I am working…
sasms
  • 21
  • 3
0
votes
0 answers

SQLite upsert for android

i have create next table: final String SQL_CREATE_TABLE_NEWS_TAPE = "CREATE TABLE " + NewsTapeEntry.TABLE_NAME + " (" + NewsTapeEntry.NEWS_ID + " INTEGER PRIMARY KEY, " + NewsTapeEntry.USER_ID + " INTEGER NOT NULL, "…
Stan Malcolm
  • 2,740
  • 5
  • 32
  • 53
0
votes
1 answer

MYSQL - Upsert from one table to another

I am trying to use upsert to update and or insert from another table INSERT INTO table1 ( `uniqueCol1`, `uniqueCol2`, `created`, `dataCol` ) VALUES ( 1, t1.uniqueCol2Value, NOW(), t1.dataColValue ) ON DUPLICATE KEY…
Nexus9988
  • 79
  • 1
  • 11
0
votes
1 answer

Access denied when using Upsert with MySQL2 and Rails 4

I'm using the Upsert gem with Rails 4.2.1 and mysql2 gem v0.3.18. But I keep getting an "Access denied" error whenever I try to upsert anything. For example: upsert = Upsert.new User.connection, User.table_name seems to work fine. But when I…
Joe
  • 53
  • 6
0
votes
1 answer

Couchbase Bulk loading error with upsert() (.NET SDK 2.0)

I have encountering an error when inserting bulk data with the upsert function and cannot figure out how to fix it. Anyone know what is wrong here? What the program is essentially doing is grabbing data from a SQL server database and loading into…
acac99
  • 3
  • 1