#63 open
Luiz Alberto Zaiats

SqlBuilder.class.php #2

Reported by Luiz Alberto Zaiats | February 6th, 2009 @ 03:38 PM | in 0.30

Hi Kris,

I've just found another BUG ('cause i am full time using you framework here ;) When using a column of type Float, the query builder renders my_column = 1.1 where it has to render my_column LIKE 1.1 (at least in MySQL). Look the code bellow:


protected function whereHelper() {
		$sql = '';
		
		$first = true;
		if(!empty($this->conditions)) {
			foreach($this->conditions as $clause) {
				if(!$first) { $sql .= ' AND '; } else { $first = false; } // TODO: Figure out how we'll do ORing
				$sql .= $clause->column . ' ' . $clause->operator . ' ' . $clause->getQueryParameter();
			}
		}
		
		if($this->useAssignmentsAsConditions && !empty($this->assignments)) {
			$assignments = $this->cleansedAssignmentsAsConditions();
			foreach($assignments as $clause) {
				if(!$first) { $sql .= ' AND '; } else { $first = false; } // TODO: Figure out how we'll do ORing
				//$sql .= $clause->column . ' **=** ' . $clause->getQueryParameter();
				$sql .= $clause->column . ' **LIKE** ' . $clause->getQueryParameter();
			}
		}
		
		if($sql != '') {
			$sql = ' WHERE ' . $sql;
		}
		
		return $sql;
	}

The code above is just a QUICK & DIRTY fix so i can continue with my development.

Comments and changes to this ticket

  • Kris Jordan

    Kris Jordan February 16th, 2009 @ 02:20 PM

    • Milestone set to 0.11.1
    • State changed from “new” to “open”

    Good catch. I will add a specific test case to the suite for MySQL and find a work around. First thought is we could use PHP's type checking to determine if it is a float. Thanks for the bug submission!

  • Kris Jordan

    Kris Jordan March 30th, 2009 @ 09:55 PM

    • Milestone changed from 0.11.1 to 0.12

    Need to double check this ticket. Rolling into next maintenance release.

  • Kris Jordan

    Kris Jordan March 31st, 2009 @ 01:40 PM

    • Milestone changed from 0.12 to 0.30

    Using LIKE in MySql appears to convert the double/float to a string and do string comparison as per http://viralpatel.net/blogs/2008...

    The recommendation is to use between() and specify an upper and lower bounds separated by a very small delta.

    Moving this ticket to 0.30 which focuses on Model functionality.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Recess PHP Framework is an open source, full stack, RESTful PHP framework.

http://www.recessframework.org/

People watching this ticket

Pages