foreign_keys = 0N with Entity Framework 6.2.0

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

foreign_keys = 0N with Entity Framework 6.2.0

Urs Wagner
The following code is returning 0. Why?


        var objectContext = ((IObjectContextAdapter) this).ObjectContext;

        objectContext.ExecuteStoreCommand("PRAGMA foreign_keys = ON;");

        var foreignKeys = objectContext.ExecuteStoreQuery<int>("PRAGMA foreign_keys;").First();

I explicitely set the pragma foreign_keys to ON.



Thanks



Urs
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Simon Slavin-3
On 12 Sep 2018, at 2:04pm, Urs Wagner <[hidden email]> wrote:

> The following code is returning 0. Why?

Which version of SQLite ?

You coerce the result of the call into an integer.  Can you make the call and display (or use a debugger to see) exactly what it's returning ?

If you do "PRAGMA compile_options" are either of these returned ?

SQLITE_OMIT_FOREIGN_KEY
SQLITE_OMIT_TRIGGER

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Urs Wagner
SQLite 3.24.0
Entity Framework 6.2.0

The result cannot be coerced into a string (compiler error).

PRAGMA compilie_options does not return any of

SQLITE_OMIT_FOREIGN_KEY
SQLITE_OMIT_TRIGGER

Regards Urs

-----Original Message-----
From: sqlite-users [mailto:[hidden email]] On Behalf Of Simon Slavin
Sent: Wednesday, September 12, 2018 7:10 PM
To: SQLite mailing list
Subject: Re: [sqlite] foreign_keys = 0N with Entity Framework 6.2.0

On 12 Sep 2018, at 2:04pm, Urs Wagner <[hidden email]> wrote:

> The following code is returning 0. Why?

Which version of SQLite ?

You coerce the result of the call into an integer.  Can you make the call and display (or use a debugger to see) exactly what it's returning ?

If you do "PRAGMA compile_options" are either of these returned ?

SQLITE_OMIT_FOREIGN_KEY
SQLITE_OMIT_TRIGGER

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Clemens Ladisch
Urs Wagner wrote:
> Simon Slavin:
>> On 12 Sep 2018, at 2:04pm, Urs Wagner <[hidden email]> wrote:
>>> The following code is returning 0. Why?
>>>
>>> ExecuteStoreQuery<int>("PRAGMA foreign_keys;").First();
>>
>> You coerce the result of the call into an integer.  Can you make the call and display (or use a debugger to see) exactly what it's returning ?
>
> The result cannot be coerced into a string (compiler error).

How exactly did you try that?

Anyway, how many rows does the corresponding EXPLAIN return, two or three?

 sqlite> explain pragma foreign_keys = on;
 addr  opcode         p1    p2    p3    p4             p5  comment
 ----  -------------  ----  ----  ----  -------------  --  -------------
 0     Init           0     1     0                    00  Start at 1
 1     Expire         0     0     0                    00
 2     Halt           0     0     0                    00
 sqlite> explain pragma do_what_i_want;
 addr  opcode         p1    p2    p3    p4             p5  comment
 ----  -------------  ----  ----  ----  -------------  --  -------------
 0     Init           0     1     0                    00  Start at 1
 1     Halt           0     0     0                    00


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Urs Wagner

Thanks for Your help

I get three lines

explain pragma foreign_keys = on

"0" "Init" "0" "1" "0" "" "00"
"1" "Expire" "0" "0" "0" "" "00"
"2" "Halt" "0" "0" "0" "" "00"

explain pragma do_what_i_want

"0" "Init" "0" "1" "0" "" "00"
"1" "Halt" "0" "0" "0" "" "00"


Is think it has to do with the entity framework. When I am using ExceuteStoreQuery or SqlQuery the foreign_keys is always 0.

Regards Urs


-----Original Message-----
From: sqlite-users [mailto:[hidden email]] On Behalf Of Clemens Ladisch
Sent: Thursday, September 13, 2018 2:23 PM
To: [hidden email]
Subject: Re: [sqlite] foreign_keys = 0N with Entity Framework 6.2.0

Urs Wagner wrote:
> Simon Slavin:
>> On 12 Sep 2018, at 2:04pm, Urs Wagner <[hidden email]> wrote:
>>> The following code is returning 0. Why?
>>>
>>> ExecuteStoreQuery<int>("PRAGMA foreign_keys;").First();
>>
>> You coerce the result of the call into an integer.  Can you make the call and display (or use a debugger to see) exactly what it's returning ?
>
> The result cannot be coerced into a string (compiler error).

How exactly did you try that?

Anyway, how many rows does the corresponding EXPLAIN return, two or three?

 sqlite> explain pragma foreign_keys = on;
 addr  opcode         p1    p2    p3    p4             p5  comment
 ----  -------------  ----  ----  ----  -------------  --  -------------
 0     Init           0     1     0                    00  Start at 1
 1     Expire         0     0     0                    00
 2     Halt           0     0     0                    00
 sqlite> explain pragma do_what_i_want;
 addr  opcode         p1    p2    p3    p4             p5  comment
 ----  -------------  ----  ----  ----  -------------  --  -------------
 0     Init           0     1     0                    00  Start at 1
 1     Halt           0     0     0                    00


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Clemens Ladisch
Urs Wagner wrote:
> I get three lines

With some other tool, or executed through the EF?


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Keith Medcalf
In reply to this post by Urs Wagner

PRAGMA xxxxx[=xx] is DML not DDL, though it might not return any rows, but it is a query.  Have you tried running the pragma foreign_keys=1; as a DML (which may return results) rather than as DDL (which do not).  Perhaps the entity framework is not executing the statement completely.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Urs Wagner
>Sent: Thursday, 13 September, 2018 06:36
>To: SQLite mailing list
>Subject: Re: [sqlite] foreign_keys = 0N with Entity Framework 6.2.0
>
>
>Thanks for Your help
>
>I get three lines
>
>explain pragma foreign_keys = on
>
>"0" "Init" "0" "1" "0" "" "00"
>"1" "Expire" "0" "0" "0" "" "00"
>"2" "Halt" "0" "0" "0" "" "00"
>
>explain pragma do_what_i_want
>
>"0" "Init" "0" "1" "0" "" "00"
>"1" "Halt" "0" "0" "0" "" "00"
>
>
>Is think it has to do with the entity framework. When I am using
>ExceuteStoreQuery or SqlQuery the foreign_keys is always 0.
>
>Regards Urs
>
>
>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Clemens Ladisch
>Sent: Thursday, September 13, 2018 2:23 PM
>To: [hidden email]
>Subject: Re: [sqlite] foreign_keys = 0N with Entity Framework 6.2.0
>
>Urs Wagner wrote:
>> Simon Slavin:
>>> On 12 Sep 2018, at 2:04pm, Urs Wagner <[hidden email]>
>wrote:
>>>> The following code is returning 0. Why?
>>>>
>>>> ExecuteStoreQuery<int>("PRAGMA foreign_keys;").First();
>>>
>>> You coerce the result of the call into an integer.  Can you make
>the call and display (or use a debugger to see) exactly what it's
>returning ?
>>
>> The result cannot be coerced into a string (compiler error).
>
>How exactly did you try that?
>
>Anyway, how many rows does the corresponding EXPLAIN return, two or
>three?
>
> sqlite> explain pragma foreign_keys = on;
> addr  opcode         p1    p2    p3    p4             p5  comment
> ----  -------------  ----  ----  ----  -------------  --  ----------
>---
> 0     Init           0     1     0                    00  Start at 1
> 1     Expire         0     0     0                    00
> 2     Halt           0     0     0                    00
> sqlite> explain pragma do_what_i_want;
> addr  opcode         p1    p2    p3    p4             p5  comment
> ----  -------------  ----  ----  ----  -------------  --  ----------
>---
> 0     Init           0     1     0                    00  Start at 1
> 1     Halt           0     0     0                    00
>
>
>Regards,
>Clemens
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: foreign_keys = 0N with Entity Framework 6.2.0

Scott Robison-2
In reply to this post by Urs Wagner
On Thu, Sep 13, 2018 at 2:05 AM Urs Wagner <[hidden email]> wrote:
>
> SQLite 3.24.0
> Entity Framework 6.2.0
>
> The result cannot be coerced into a string (compiler error).

Maybe I'm misreading this, but the subject line shows "foreign_keys =
[zero][en]" ... it appears the word ON ([oh][en]) is being written as
0N ([zero][en]) instead.

Maybe that's just an email typo, but thought I'd point it out.

--
Scott Robison
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users