Fields changes?

Posts   
 
    
sgay
User
Posts: 53
Joined: 23-Nov-2006
# Posted on: 17-Jan-2008 16:26:52   

Consider the following code (stripped of all the error-handling code), which is running in adapter mode with EntityBase2.MarkSavedEntitiesAsFetched = true:

var p1 = new FooEntity();
var p2 = new FooEntity();

p1.Name = "foo";
adapter.SaveEntity(p1, false, false);

p2.Id = p1.Id;
adapter.FetchEntity(p2);

// SAVE-P2
p2.Name = p2.Name;
adapter.SaveEntity(p2, false, false);

// SAVE-P1
p1.Name = p1.Name;
adapter.SaveEntity(p1, false, false);

SAVE-P2 does not trigger any SQL UPDATE because p2.IsDirty is false because p2.Name has not actually changed.

SAVE-P1_does_ trigger an SQL UPDATE and p1.Fields["Name"].IsChanged is true. Why?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Jan-2008 08:45:47   

Which version of LLBLGen Pro runtime libraries are you using? Would you please attach a repro solution against Northwind if possible?

Thanks

sgay
User
Posts: 53
Joined: 23-Nov-2006
# Posted on: 18-Jan-2008 10:40:08   

Walaa wrote:

Which version of LLBLGen Pro runtime libraries are you using? Would you please attach a repro solution against Northwind if possible?

This is with 2.5.7.1119 and a custom MySql driver (i.e. not the one requiring CoreLab's library) so I'll look further into it and come back to you when I have a clean repro solution.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 10:47:03   

Reproduced. Very strange. If I refetch the entity, it works, if I use the mark as fetched flag, it indeed doesn't work. Looking into it.


[Test]
public void SavedEntityMarkedAsFetchedRetriggersIsDirtyTest()
{
    AddressEntity address = EntityCreator.CreateNewAddress(1);
    bool flagSave = EntityBase2.MarkSavedEntitiesAsFetched;
    EntityBase2.MarkSavedEntitiesAsFetched = true;
    Assert.IsTrue(address.Fields[(int)AddressFieldIndex.StreetName].IsChanged);
    try
    {
        Assert.IsTrue(address.IsDirty);
        using(DataAccessAdapter adapter = new DataAccessAdapter())
        {
            adapter.SaveEntity(address, false, false);
        }
        Assert.IsFalse(address.Fields[(int)AddressFieldIndex.StreetName].IsChanged);
        Assert.IsFalse(address.IsDirty);
        Assert.IsFalse(address.IsNew);
        address.StreetName = address.StreetName;
        Assert.IsFalse(address.IsDirty);
    }
    finally
    {
        EntityBase2.MarkSavedEntitiesAsFetched = flagSave;
    }
}

Edit: interesting: you use a custom mysql provider? MySql's own? Be aware that if you use the GPL-ed version, you have to re-license the DQE code as it has to be GPL-ed as well due to MySql's GPL-ed provider, something which you can't do.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 10:51:09   

Found it. The routine which flags the entity as fetched doesn't copy over CurrentValue into DbValue for the fields in the entity. This is done with a fetch, but not with this action, so DbValue is null, which will trigger a change. Will fix it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 11:08:12   

Fixed in next build (01182008 )

Frans Bouma | Lead developer LLBLGen Pro
sgay
User
Posts: 53
Joined: 23-Nov-2006
# Posted on: 18-Jan-2008 11:12:45   

Otis wrote:

Fixed in next build (01182008 )

Great, many thanks. Will download asap and test.

sgay
User
Posts: 53
Joined: 23-Nov-2006
# Posted on: 18-Jan-2008 11:38:12   

Otis wrote:

Edit: interesting: you use a custom mysql provider? MySql's own? Be aware that if you use the GPL-ed version, you have to re-license the DQE code as it has to be GPL-ed as well due to MySql's GPL-ed provider, something which you can't do.

We use custom MySql driver and DQE built against MySql's Connector.Net v5.x. Was relatively easy to setup, works like a charm as far as I can tell.

We had discussions on this forum in the past re. the connector being GPL-ed (http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8197) and I also had discussions about it with MySql in France[0].

Our current position is: a) The application is used internally and not to be redistributed, so we're clean with regards to the GPL; b) Should we want to redistribute the application in the future, we would either switch back to using CoreLab's provider, or jump to PostgreSQL.

Stephen

[0] MySql France reps seemed to barely understand the problem and did a terrific job at being as evasive as possible and trying to sell their commercial license... pure nonsense.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 11:50:59   

sgay wrote:

Otis wrote:

Fixed in next build (01182008 )

Great, many thanks. Will download asap and test.

It's not currently available. I've to fix another bug (the fix is designed and working in selfservicing, have to port the code to adapter) as well before it will be released. That bug is unrelated to this one (using type filters in some typedlists goes wrong).

I'll post a new post with the link to the updated build here when it's done (expect it in a few hours)

[0] MySql France reps seemed to barely understand the problem and did a terrific job at being as evasive as possible and trying to sell their commercial license... pure nonsense.

That's my experience with Mysql AB as well. I tried several times to contact their laywers about this problem and to get their position on this (as it could give problems for customers who distribute their work which was build with the commercial version of their provider), but they never tried to understand the problem. All they ever replied was the same boring salespitch that we should become a MySql VAR. Very annoying. Also their refusal to place the commercial license of the .net provider on their website is annoying. You have to contact a var to get a license, which isn't cheap (250 euros if I'm not mistaken).

Core Lab's also not great, but IMHO it's the only option people have when they want to use MySql, at least it's more cheaper. People think it's not but they don't know hte price of MySql's provider, and often refuse to understand what the GPL license means for them. (even distributing an app internally from one department to another is a violation)

Let's hope that Sun will change the license into LGPL, but I doubt it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 14:49:20   

Btw, the latest build is attached here: http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=68537&ThreadID=12329

If you don't need it today, you can wait till the next build is released. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
sgay
User
Posts: 53
Joined: 23-Nov-2006
# Posted on: 18-Jan-2008 17:20:02   

Otis wrote:

Btw, the latest build is attached here: http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=68537&ThreadID=12329

If you don't need it today, you can wait till the next build is released. simple_smile

I can confirm that this build does fix the issue. I'll download the 'official' build as soon as it is available.

Thanks for the quick fix! Stephen

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 18-Jan-2008 18:14:50   

sgay wrote:

Otis wrote:

Btw, the latest build is attached here: http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=68537&ThreadID=12329

If you don't need it today, you can wait till the next build is released. simple_smile

I can confirm that this build does fix the issue. I'll download the 'official' build as soon as it is available.

Thanks for the quick fix! Stephen

I've to tell you that this build contains a bug, in the typedlist/dyn. list code. Currently working on a fix for that. So I'd use the officially released build instead of this preliminairy build I linked to above, as that one has been pulled now. Sorry for this inconvenience.

(edit) the bug was fixed. I've reattached the build to that thread)

Frans Bouma | Lead developer LLBLGen Pro