Comments (7)
I probably did not phrase the bug report correctly. I have two SQL queries that have worked perfectly from CI version 4.0.x all the way through 4.4.8. Both of these queries are constructed using the Query Builder Class. Here are the lines from each Query Builder that appear to be throwing the type error:
->join('leases', 'units.unit_id = leases.unit_id AND CURDATE() BETWEEN lease_start_date AND lease_exp_date', 'left')
->join('leases', 'units.unit_id = leases.unit_id AND workorder_start BETWEEN lease_start_date AND lease_exp_date', 'left')
The only common thread seems to be the use of the BETWEEN SQL operator. I'm not sure that has anything to do with it.
It does seem to be an issue in Query Builder because it no longer puts together the query without throwing an error.
It could simply be a strict typing issue like some of the other 4.5.0 bugs, but I will do some further troubleshooting.
from codeigniter4.
How do we reproduce?
It seems Query Builder does not support BETWEEN.
https://codeigniter4.github.io/CodeIgniter4/database/query_builder.html
from codeigniter4.
Thank you for the feedback.
There is no sample code with BETWEEN
in join()
.
https://codeigniter4.github.io/CodeIgniter4/database/query_builder.html#join
and there is no test case:
https://github.com/codeigniter4/CodeIgniter4/blob/develop/tests/system/Database/Builder/JoinTest.php
We need further investigation.
from codeigniter4.
It seems join()
does not support BETWEEN
, but it worked by accident in previous versions.
When there is a conditon 'units.unit_id = leases.unit_id AND CURDATE() BETWEEN lease_start_date AND lease_exp_date'
, it is parsed in $conditions
as
array (
0 => 'units.unit_id = leases.unit_id',
1 => 'CURDATE() BETWEEN lease_start_date',
2 => 'lease_exp_date',
)
but it is of course wrong.
Fixing this behavior is difficult, so I sent ad hoc fix PR #8792
from codeigniter4.
Ahh, I understand now.
I replaced the BETWEEN
operators in my JOIN
clauses with a combination of >=
and <=
operators to workaround this limitation with Query Builder.
This project also has many WHERE
clauses constructed by Query Builder utilizing the BETWEEN
operator that are still working as expected in 4.5.1. Does where()
officially support BETWEEN
or is is this also working by accident?
from codeigniter4.
There is one test case.
CodeIgniter4/tests/system/Database/Builder/WhereTest.php
Lines 198 to 210 in d425bdf
But note that uses
false
in the third parameter $escape
:If $escape
is set to false, the value as is becomes a part of the SQL statement, so you can freely create SQL statements, but QueryBuilder does not provide any protection/escaping.
from codeigniter4.
@oakhurstmgmt If you agree to merge #8792, approve the PR.
from codeigniter4.
Related Issues (20)
- Bug: language fallback doesn't kick in if message if empty HOT 5
- Bug: Session FileDriver unlink No such file or directory HOT 1
- feat: Command `lang:find` behavior with parameters
- Bug: Credit card validation does not work with multiple card HOT 1
- Bug: postgre can not connect to database error HOT 12
- `Model::paginate()` behavior when `$page` exceeds the last page HOT 12
- Bug: CodeIgniter v4.5.1 When I connect Postgres Database I Received Error HOT 4
- Bug: [Error] Call to undefined method Config\Mimes::__set_state() at ROOTPATH/writable/cache/FactoriesCache_config HOT 7
- Bug: [DebugBar] Flush a session flash-data when redirect by "Refresh" method HOT 2
- Add required_if validation rules
- Bug: Entity Standalone Class initialization error HOT 2
- Bug: How can I know which browser name is the request from?
- Bug: How can I know which browser name is the request from? HOT 14
- Bug: storing validation rules in Config/Validation causes error HOT 1
- Bug: Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /var/www/html/MyApp/system/Common.php:777 HOT 1
- Bug: cannot run PHPUnit testing in CI 4.5.1 appstarter HOT 5
- "Deploy API Documentation" fails HOT 1
- Bug: Composer PSR-4 notices HOT 6
- Bug: CodeIgniter\Router\RouteCollection::getRoutesOptions(): Argument #1 ($from) must be of type ?string, int given, called in system\Router\DefinedRouteCollector.php on line 49 HOT 1
- Bug: migration:rollback impossible due to argument 1 type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codeigniter4.