RE: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Lee Crain
No, I'm not performing Outer Joins. 

This problem occurs on an INSERT statement.

A QString object's pointer to memory is ZERO unless an assignment is made.


Performing: -> QString object = "";

solves the problem.

Lee





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 12:39 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How Does NOT NULL produce NULLs?

"Lee Crain" <[EMAIL PROTECTED]> wrote:
> I did expect SQLite to enforce the NOT NULL portion of the SQL
> creation statements, no matter what.

SQLite *does* enforce NOT NULL no matter what.  I think your
pointers are getting turned into NULLs someplace else, perhaps
somewhere in the QT layer.

A NULL can get inserted for NOT NULL columns for non-matching
rows of an OUTER JOIN.  Are you doing OUTER JOINs?  The NOT NULL
applies to the table, not to query results from the table.

Also, if you request a invalid column (the column number is too
large or too small, or the last call to sqlite3_step() did not
return SQLITe_ROW), then the SQLite interfaces will return a 
NULL pointer.

--
D. Richard Hipp <[EMAIL PROTECTED]>


--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread drh
"Lee Crain" <[EMAIL PROTECTED]> wrote:
> I did expect SQLite to enforce the NOT NULL portion of the SQL
> creation statements, no matter what.

SQLite *does* enforce NOT NULL no matter what.  I think your
pointers are getting turned into NULLs someplace else, perhaps
somewhere in the QT layer.

A NULL can get inserted for NOT NULL columns for non-matching
rows of an OUTER JOIN.  Are you doing OUTER JOINs?  The NOT NULL
applies to the table, not to query results from the table.

Also, if you request a invalid column (the column number is too
large or too small, or the last call to sqlite3_step() did not
return SQLITe_ROW), then the SQLite interfaces will return a 
NULL pointer.

--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Lee Crain
A "bug" in "my" code is possible. 

We are using the QT suite and QString objects do not distinguish between
an uninitialized QString object (pointer == zero) and an empty string ("")
which I think is a flawed lack of distinction. In Lee Crain's Rules Of
Software Development Practices, NULL means nothing is known; empty means
empty. The 2 conditions are distinctly and unambiguously different.

However, I did expect SQLite to enforce the NOT NULL portion of the SQL
creation statements, no matter what. If it cannot for whatever reason,
then I will enforce it in my source code by:

if( 0 == QString.Length( ) )
{
// QString object's state is ambiguous; can be NULL or empty,
//  according to QT documentation.
QString = ""; // This line solves the problem.
}

Thanks for your responses,

Lee Crain

__


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 12:02 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How Does NOT NULL produce NULLs?

"Lee Crain" <[EMAIL PROTECTED]> wrote:
> I've created a table with several fields, 3 of which are created using
> these SQL statements:
> 
> [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> 
> [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> 
> [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);
> 
> __
> 
> Subsequent data insertions of empty strings produce the following data:
> 
> (null)|(null)|(null)  
> 

I am unable to replicate the problem.  Are you sure you don't
have a bug in *your* code?

--
D. Richard Hipp <[EMAIL PROTECTED]>


--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Cory Nelson
On Jan 29, 2008 11:01 AM,  <[EMAIL PROTECTED]> wrote:
> "Lee Crain" <[EMAIL PROTECTED]> wrote:
> > I've created a table with several fields, 3 of which are created using
> > these SQL statements:
> >
> > [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> >
> > [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> >
> > [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);
> >
> > __
> >
> > Subsequent data insertions of empty strings produce the following data:
> >
> > (null)|(null)|(null)
> >
>
> I am unable to replicate the problem.  Are you sure you don't
> have a bug in *your* code?

It looks to me like he is passing a null pointer to printf.

-- 
Cory Nelson

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Lee Crain
Scott,

I'm not ignoring your post. I'm going to respond to DRH's post.

Thanks,

Lee

_

-Original Message-
From: Scott Hess [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 11:54 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How Does NOT NULL produce NULLs?

That seems unlikely, since NULL wouldn't come out as the string (null)
in any case.  Most likely some higher layer is putting the literal
'(null)' in for you when you insert.  Please post a set of literal
input to sqlite3 which demonstrates the problem.

.nullvalue '[null]'
create table x (
  [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
  [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
  [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE
);
insert into x values ('', '', '');
insert into x (description) values ('x');

Outputs:
||
x||

Just what I'd expect.

create table y (
  [description] [varchar](255) COLLATE NOCASE,
  [keywords][varchar](255) COLLATE NOCASE,
  [metadata][varchar](255) COLLATE NOCASE
);
insert into y values ('', '', '');
insert into y (description) values ('x');
select * from y;

Outputs:
||
x|[null]|[null]

Again, just what I'd expect.

This under SQLite version 3.5.4.

-scott


On Tue, Jan 29, 2008 at 10:12 AM, Lee Crain <[EMAIL PROTECTED]> wrote:
> I've created a table with several fields, 3 of which are created using
>  these SQL statements:
>
>  [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
>
>  [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
>
>  [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);
>
>  __
>
>  Subsequent data insertions of empty strings produce the following data:
>
>  (null)|(null)|(null)
>
>  __
>
>  It is important in the application this data is associated with to NOT
>  have any NULL fields. To me, an empty string is not a NULL, only an
empty
>  string, an important distinction.
>
>  How can I prevent the insertion of NULLs into these fields and instead
>  replace them with empty strings?
>
>  Lee Crain
>
>
--
---
>  To unsubscribe, send email to [EMAIL PROTECTED]
>
--
---
>
>

--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread drh
"Lee Crain" <[EMAIL PROTECTED]> wrote:
> I've created a table with several fields, 3 of which are created using
> these SQL statements:
> 
> [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> 
> [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
> 
> [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);
> 
> __
> 
> Subsequent data insertions of empty strings produce the following data:
> 
> (null)|(null)|(null)  
> 

I am unable to replicate the problem.  Are you sure you don't
have a bug in *your* code?

--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Scott Hess
That seems unlikely, since NULL wouldn't come out as the string (null)
in any case.  Most likely some higher layer is putting the literal
'(null)' in for you when you insert.  Please post a set of literal
input to sqlite3 which demonstrates the problem.

.nullvalue '[null]'
create table x (
  [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
  [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
  [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE
);
insert into x values ('', '', '');
insert into x (description) values ('x');

Outputs:
||
x||

Just what I'd expect.

create table y (
  [description] [varchar](255) COLLATE NOCASE,
  [keywords][varchar](255) COLLATE NOCASE,
  [metadata][varchar](255) COLLATE NOCASE
);
insert into y values ('', '', '');
insert into y (description) values ('x');
select * from y;

Outputs:
||
x|[null]|[null]

Again, just what I'd expect.

This under SQLite version 3.5.4.

-scott


On Tue, Jan 29, 2008 at 10:12 AM, Lee Crain <[EMAIL PROTECTED]> wrote:
> I've created a table with several fields, 3 of which are created using
>  these SQL statements:
>
>  [description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
>
>  [keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,
>
>  [metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);
>
>  __
>
>  Subsequent data insertions of empty strings produce the following data:
>
>  (null)|(null)|(null)
>
>  __
>
>  It is important in the application this data is associated with to NOT
>  have any NULL fields. To me, an empty string is not a NULL, only an empty
>  string, an important distinction.
>
>  How can I prevent the insertion of NULLs into these fields and instead
>  replace them with empty strings?
>
>  Lee Crain
>
>  -
>  To unsubscribe, send email to [EMAIL PROTECTED]
>  -
>
>

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] How Does NOT NULL produce NULLs?

2008-01-29 Thread Lee Crain
I've created a table with several fields, 3 of which are created using
these SQL statements:

[description] [varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,  

[keywords][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE,  

[metadata][varchar](255) NOT NULL DEFAULT ('') COLLATE NOCASE);

__

Subsequent data insertions of empty strings produce the following data:

(null)|(null)|(null)

__

It is important in the application this data is associated with to NOT
have any NULL fields. To me, an empty string is not a NULL, only an empty
string, an important distinction. 

How can I prevent the insertion of NULLs into these fields and instead
replace them with empty strings?

Lee Crain

-
To unsubscribe, send email to [EMAIL PROTECTED]
-