К основному контенту

Сообщения

Сообщения за октябрь, 2008

Fixing invisible or disappearing text and double margins in Internet Explorer

This How-to applies to: Any version. This How-to is intended for: Integrators, Customizers Internet Explorer has a very serious bug when calculating the height of floating elements, which can cause elements to disappear. Here's a simple way to work around it in any layout, with a special convenience class for Plone - although the approach is valid for any CSS layout. The problem Displaying a page in Internet Explorer causes text to disappear, or elements to be wider than their proper width. There is not general way to fix this problem on a page-wide scale, so you have to test your pages in Internet Explorer and see if they exhibit this behaviour. If they do, you can apply a simple class to that element, and it will behave the way you intended again. Some examples Below are a couple of examples of the bug as they normally appear in Plone: The classic example of disappearing text in Internet Explorer. Here we see that the headline of the Plone welcome page is only visible when sele...

SQL WHERE clauses: Avoid CASE, use Boolean logic

As some of you may know, I recommend to avoid using CASE expressions in the WHERE clause of a query to express conditional logic. I prefer to have everything translated to simple ANDs, ORs and NOTs to keep things a) portable, b) easier to read and c) efficient. Learning some good boolean logic techniques will go a long way towards making your queries more efficient, and you won't need to rely on CASE's and other methods of doing conditional logic. First off, when I say “conditional logic”, I am talking about something like this: “If A then B” where A and B are both conditions. For example, in a WHERE clause, you might want to implement a condition like this: “If (@ReturnAll 1) THEN (EmpID = @EmpID)” To express this logic in the WHERE clause, many people might code it like this: WHERE EmpID = CASE WHEN @ReturnAll 1 THEN @EmpID ELSE EmpID END However, this is kind of counter-intuitive (why should we check that EmpID = EmpID ?) and can be really tough to implement when the cond...

Optimizing Conditional WHERE Clauses: Avoiding ORs and CASE Expressions

Often, we need to create a flexible stored procedure that returns data that is optionally filtered by some parameters. If you wish to apply a filter, you set the parameter to the necessary value, if not, you leave it null. This is pretty standard stuff, of course, that we can write fairly easily, without the need for dynamic SQL, like this: create procedure GetData @MinDate int = null, @MaxDate int = null, @MinAmount money = null, @MaxAmount money = null, @ProductCode varchar(200) = null, @CompanyID int as select * from Data where (@MinDate is null OR @MinDate (@MaxDate is null OR @MaxDate >= Date) and (@MinAmount is null OR @MinAmount >= Amount) and (@MaxAmount is null OR @MaxAmount (@ProductCode is null OR ProductCode = @ProductCode) and (@CompanyID is null OR CompanyID = @CompanyID) Note that we are using good boolean algebra as discussed here, and not using inefficient CASE or COALESCE() exp...