Upsert not adding new field

using sdk 2.7.6 I am doing an upsert with a new field but while the upsert is successful my new field is not in the db. My new field is called viewedUpdate, I verified it has data and the upsert .Success thinks it worked, am I missing something?

I even tried creating the field in the admin tool but it does not get updated

my connection is fine, I can open the bucket successfully and the server is 6.5.0 build 4960 (windows)

any suggestions appreciated

dougc

here is the code

var document = new Document
{
Id = rowId,
Content = new
{
issue = issue,
title = tmptitle,
subCatagory = subCatagory,
catagory = catagory,
status = status,
severity = severity,
childrenJira = childrenJira,
parentJira = parentJira,
marketCountry = marketCountry,
updateDate = updateDate,
updateTime = updateTime,
updateCtr = updateCtr,
createDate = createDate,
createTime = createTime,
endDate = endDate,
endTime = endTime,
startDate = startDate,
startTime = startTime,
ownership = ownership,
notifyUser = notifyUser,
businessImpact = businessImpact,
viewedUpdate = viewedUpdate
}
};

                    var upsert = bucket.Upsert(document);
                    if (upsert.Success)
                    {
                        MessageBox.Show("upsert successful", "successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

here is the record in couchbase
its the last “field” viewedUpdate
{
“marketCountry”: “CANADA”,
“catagory”: “Corporate”,
“severity”: “2”,
“issue”: “testing new incident has the viewupdated field\r\n\r\nAdded by dougc @ 5/6/2020 10:30:40 PM”,
“createDate”: “05/6/2020”,
“createTime”: “22:30”,
“status”: “OPEN”,
“parentJira”: “N/A”,
“childrenJira”: “N/A”,
“title”: “new field test viewedupdated”,
“updateCtr”: 0,
“startDate”: “”,
“startTime”: “”,
“ownership”: “”,
“notifyUser”: “yes”,
“subcatagory”: “Autoship”,
“updateDate”: “5/6/2020”,
“updateTime”: “22:36”,
“endDate”: “”,
“endTime”: “”,
“businessImpact”: “”,
“viewedUpdate”: “”
}

Hi @dougc,

I just tried this locally, and it seems to work okay (my code example is below). Some things you might want to look at:

  1. In your record, there IS a viewedUpdate field, it’s an empty string. This seems to indicate that whatever value you’re setting viewedUpdate to is an empty string.

  2. Probably not related, but 2.7.17 is the latest 2.x SDK release. Might be worth upgrading, but again, I doubt it’s related to your issue.

  3. “I even tried creating the field in the admin tool but it does not get updated” - I also tried in the admin tool and it worked fine. When you tried, did you get an error message? What happened?


Here’s the minimum example that I used to try it out. It doesn’t look like there’s anything special about viewedUpdate, it’s not a reserved word or anything. After I run this:

    var cluster = new Cluster(new ClientConfiguration
    {
        Servers = new List<Uri> {  new Uri("http://localhost:8091")}
    });
    cluster.Authenticate("Administrator", "password");
    var bucket = cluster.OpenBucket("default");

    var document = new Document<dynamic>
    {
        Id = "foo",
        Content = new
        {
            viewedUpdate = DateTime.Now
        }
    };

    var upsert = bucket.Upsert(document);
    if (upsert.Success)
        Console.WriteLine("upsert successful");

    cluster.Dispose();

This is what I see in the UI:

screenshot

thank you for the reply, I will look at updating to the 2.7.17 and when I added the field in the admin tool it created just fine, I will look at your suggestion that maybe the data I am trying to upsert somehow is null

again thank you

thanks for your help while looking for the complicated I missed the simple and once I sat back thought about what you said (relooked at my code) it slapped me like I had made an inappropriate comment to my mother …

sorry about that and again thanks of your help, this is one of the reasons I really love couchbase

thanks dougc

It happens to all of us @dougc, have a good weekend :slight_smile: