Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
e3f5aa9f
Commit
e3f5aa9f
authored
Sep 26, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boolean type bugs fixed, fixes #101
Ticket: 101
parent
2c16937d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
41 deletions
+74
-41
Hydrate.php
lib/Doctrine/Hydrate.php
+13
-0
Where.php
lib/Doctrine/Query/Where.php
+6
-1
Record.php
lib/Doctrine/Record.php
+7
-0
Getting started - Setting table definition - Data types and lengths.php
...d - Setting table definition - Data types and lengths.php
+1
-2
documentation.php
manual/documentation.php
+16
-27
BooleanTestCase.php
tests/BooleanTestCase.php
+21
-3
DataDictSqliteTestCase.php
tests/DataDictSqliteTestCase.php
+1
-1
run.php
tests/run.php
+9
-7
No files found.
lib/Doctrine/Hydrate.php
View file @
e3f5aa9f
...
...
@@ -235,6 +235,17 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
return
array
();
}
/**
* convertBoolean
* converts boolean to integers
*
* @param mixed $item
* @return void
*/
public
static
function
convertBoolean
(
&
$item
)
{
if
(
is_bool
(
$item
))
$item
=
(
int
)
$item
;
}
/**
* execute
* executes the dql query and populates all collections
...
...
@@ -246,6 +257,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$this
->
data
=
array
();
$this
->
collections
=
array
();
array_walk
(
$params
,
array
(
__CLASS__
,
'convertBoolean'
));
if
(
!
$this
->
view
)
$query
=
$this
->
getQuery
();
else
...
...
lib/Doctrine/Query/Where.php
View file @
e3f5aa9f
...
...
@@ -76,6 +76,11 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition {
$alias
=
$this
->
query
->
getTableAlias
(
$reference
);
$table
=
$this
->
query
->
getTable
(
$alias
);
if
(
trim
(
$value
)
==
'true'
)
$value
=
1
;
elseif
(
trim
(
$value
)
==
'false'
)
$value
=
0
;
switch
(
$operator
)
{
case
'<'
:
case
'>'
:
...
...
lib/Doctrine/Record.php
View file @
e3f5aa9f
...
...
@@ -324,6 +324,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case
"enum"
:
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
case
"boolean"
:
case
"integer"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
settype
(
$tmp
[
$name
],
$type
);
default
:
$this
->
data
[
$name
]
=
$tmp
[
$name
];
endswitch
;
...
...
@@ -889,6 +893,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case
'gzip'
:
$a
[
$v
]
=
gzcompress
(
$this
->
data
[
$v
],
5
);
break
;
case
'boolean'
:
$a
[
$v
]
=
(
int
)
$this
->
data
[
$v
];
break
;
case
'enum'
:
$a
[
$v
]
=
$this
->
table
->
enumIndex
(
$v
,
$this
->
data
[
$v
]);
break
;
...
...
manual/docs/Getting started - Setting table definition - Data types and lengths.php
View file @
e3f5aa9f
...
...
@@ -13,8 +13,7 @@ Following data types are availible in doctrine:
<
li
/><
b
>
object
</
b
>
<
ul
>
The
same
as
type
'object'
in
php
.
Automatically
serialized
when
saved
into
database
and
unserialized
when
retrieved
from
database
.</
ul
>
<
li
/><
b
>
enum
</
b
>
<
ul
>
Unified
'enum'
type
.
Automatically
converts
the
string
values
into
index
numbers
and
vice
versa
.
The
possible
values
for
the
column
can
be
specified
with
Doctrine_Record
::
setEnumValues
(
columnName
,
array
values
)
.</
ul
>
<
ul
>
</
ul
>
<
li
/><
b
>
timestamp
</
b
>
<
dd
/>
Database
'timestamp'
type
<
li
/><
b
>
clob
</
b
>
...
...
manual/documentation.php
View file @
e3f5aa9f
...
...
@@ -102,20 +102,7 @@ $menu = array("Getting started" =>
"Enum emulation"
,
),
"Data types"
=>
array
(
"Boolean"
,
"Integer"
,
"Float"
,
"String"
,
"Array"
,
"Object"
,
"Blob"
,
"Clob"
,
"Timestamp"
,
"Date"
,
"Enum"
,
"Gzip"
,
),
"Record identifiers"
=>
array
(
"Introduction"
,
"Autoincremented"
,
...
...
@@ -126,16 +113,20 @@ $menu = array("Getting started" =>
"Schema reference"
=>
array
(
"Data types"
=>
array
(
"PHP based types"
=>
array
(
"Boolean"
,
"Integer"
,
"Float"
,
"String"
,
"Array"
,
"Object"
,
"Blob"
,
"Clob"
,
"Timestamp"
,
"Date"
,
"Enum"
,
"Gzip"
,
),
),
),
"Basic Components"
=>
array
(
...
...
@@ -153,6 +144,7 @@ $menu = array("Getting started" =>
"Getting record state"
,
"Getting object copy"
,
"Serializing"
,
"Existence checking"
,
"Callbacks"
),
"Connection"
=>
array
(
"Introduction"
,
...
...
@@ -199,6 +191,10 @@ $menu = array("Getting started" =>
"Using SQL"
,
"Adding components"
,
"Method overloading"
),
"DB"
=>
array
(
"Introduction"
,
"Connecting to a database"
,
"Using event listeners"
),
/**
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
"Setting parameters",
...
...
@@ -263,6 +259,8 @@ $menu = array("Getting started" =>
"List of events"
,
"Listening events"
,
"Chaining"
,
"AccessorInvoker"
,
"Creating a logger"
,
),
"Validators"
=>
array
(
"Intruduction"
,
...
...
@@ -275,15 +273,6 @@ $menu = array("Getting started" =>
"Managing views"
,
"Using views"
),
/**
"Hook" => array(
"Introduction",
"Parameter hooking",
"Paging",
"Setting conditions",
"Sorting"
),
*/
"Cache"
=>
array
(
"Introduction"
,
"Query cache"
),
...
...
tests/BooleanTestCase.php
View file @
e3f5aa9f
...
...
@@ -31,9 +31,17 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase {
$test
=
$test
->
getTable
()
->
find
(
$test
->
id
);
$this
->
assertEqual
(
$test
->
is_working
,
true
);
}
public
function
testNormalQuerying
()
{
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = 0'
);
$this
->
assertEqual
(
count
(
$ret
),
1
);
public
function
testFetching
()
{
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = 1'
);
Doctrine_Lib
::
formatSql
(
$query
->
getQuery
());
$this
->
assertEqual
(
count
(
$ret
),
1
);
}
public
function
testPreparedQueries
()
{
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = ?'
,
array
(
false
));
$this
->
assertEqual
(
count
(
$ret
),
1
);
...
...
@@ -42,6 +50,16 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase {
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = ?'
,
array
(
true
));
$this
->
assertEqual
(
count
(
$ret
),
1
);
}
public
function
testFetchingWithSmartConversion
()
{
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = false'
);
$this
->
assertEqual
(
count
(
$ret
),
1
);
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$ret
=
$query
->
query
(
'FROM BooleanTest WHERE BooleanTest.is_working = true'
);
Doctrine_Lib
::
formatSql
(
$query
->
getQuery
());
$this
->
assertEqual
(
count
(
$ret
),
1
);
}
}
?>
tests/DataDictSqliteTestCase.php
View file @
e3f5aa9f
tests/run.php
View file @
e3f5aa9f
...
...
@@ -32,12 +32,11 @@ require_once("ImportTestCase.php");
require_once
(
"BooleanTestCase.php"
);
require_once
(
"EnumTestCase.php"
);
require_once
(
"RelationAccessTestCase.php"
);
require_once
(
"DataDictSqliteTestCase.php"
);
error_reporting
(
E_ALL
);
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_DB_TestCase
());
$test
->
addTestCase
(
new
Doctrine_ConnectionTestCase
());
...
...
@@ -76,9 +75,9 @@ $test->addTestCase(new Doctrine_RawSql_TestCase());
$test
->
addTestCase
(
new
Doctrine_Query_Limit_TestCase
());
$test
->
addTestCase
(
new
Doctrine_SchemaTestCase
());
//
$test->addTestCase(new Doctrine_SchemaTestCase());
$test
->
addTestCase
(
new
Doctrine_ImportTestCase
());
//
$test->addTestCase(new Doctrine_ImportTestCase());
$test
->
addTestCase
(
new
Doctrine_CollectionTestCase
());
...
...
@@ -93,6 +92,9 @@ $test->addTestCase(new Doctrine_EnumTestCase());
$test
->
addTestCase
(
new
Doctrine_RelationAccessTestCase
());
$test
->
addTestCase
(
new
Doctrine_EventListener_Chain_TestCase
());
$test
->
addTestCase
(
new
Doctrine_DataDict_Sqlite_TestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
@@ -124,9 +126,9 @@ if (TextReporter::inCli()) {
}
else
{
if
(
isset
(
$_POST
))
{
$dsn
=
$_POST
[
'dsn'
]
;
$username
=
$_POST
[
'username'
]
;
$password
=
$_POST
[
'password'
]
;
$dsn
=
isset
(
$_POST
[
'dsn'
])
?
$_POST
[
'dsn'
]
:
null
;
$username
=
isset
(
$_POST
[
'username'
])
?
$_POST
[
'username'
]
:
null
;
$password
=
isset
(
$_POST
[
'password'
])
?
$_POST
[
'password'
]
:
null
;
}
$test
->
run
(
new
MyReporter
());
$output
=
ob_get_clean
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment