darsain / laravel-console

In-browser console for Laravel PHP framework.
170 stars 44 forks source link

Ignore quotes when converting special characters to HTML entities #18

Closed tortuetorche closed 11 years ago

tortuetorche commented 11 years ago

Otherwise when you execute this command:

Role::create( array('name' => 'admin') );

This unreadable SQL log appears:

insert into "roles" ("name", "updated_at", "created_at") values ('admin', '2013-09-09 13:27:43', '2013-09-09 13:27:43') returning "id"
tortuetorche commented 11 years ago

FYI I use a PostgreSQL database. And it needs the " (quote) character in its SQL queries. In fact, I think that PDO adds them automagically :smile:

$sql = htmlspecialchars($sql, ENT_NOQUOTES);

darsain commented 11 years ago

If I understand it correctly: When you click on SQL tab, you see escaped entities, and not characters?

(confirm it please, so I could be sure )

If that is the case, it is a deeper problem that can't be solved just by not escaping quotes. As soon as you'll do some query with other characters that need to be escaped (like <), you'll see the entities again.

Rather, we need to figure out why is it escaped twice, and how to handle it.

tortuetorche commented 11 years ago

(confirm it please, so I could be sure )

Yes, that's the case.

As soon as you'll do some query with other characters that need to be escaped (like <), you'll see the entities again.

When you execute this command:

Role::where('id', '<', 1)->first();

it returns:

select * from "roles" where "id" < '1' limit 1

So, it's look fine.

darsain commented 11 years ago

I don't like it, but the commit above seems to be the simplest solution that is also future proof. Check if it fixes your issue please.

tortuetorche commented 11 years ago

It's OK ! Thank you @Darsain :clap: