fix views generation SQL