In file-storage/www/file-storage-procs-postgresl.xql is this query:
<fullquery name="fs::get_folder_contents.select_folder_contents">
<querytext>
select fc.*
from (select fs_objects.object_id,
fs_objects.name,
fs_objects.live_revision,
fs_objects.type,
to_char(fs_objects.last_modified, 'Month DD
YYYY HH24:MI') as last_modified,
fs_objects.content_size,
fs_objects.url,
fs_objects.key,
fs_objects.sort_key,
case when fs_objects.last_modified >= (now()
- $n_past_days) then 1 else 0 end as new_p,
acs_permission__permission_p(fs_objects.object_id, :user_id, 'admin')
as admin_p,
acs_permission__permission_p(fs_objects.object_id, :user_id, 'delete')
as delete_p,
acs_permission__permission_p(fs_objects.object_id, :user_id, 'write')
as write_p
from fs_objects
where fs_objects.parent_id = :folder_id) fc
where 't' = (select
acs_permission__permission_p(fc.object_id, :user_id, 'read') from dual)
order by fc.sort_key,
fc.name
</querytext>
</fullquery>
the now()-:n_past_days is breaking. The bind variable emulation in the
postgresql driver adds single-quotes around the n_past_days variable
resulting in the following expression:
now() - '-1'
Postgresql thinks that the integer inside the quotes is a date to
subtract and returns an error "ERROR: Bad timestamp external
representation '-1'".
I changed the :n_past_days reference to $n_past_days.
I think this is a reasonable solution. The n_past_days variable is
checked by ad_page_contract to ensure it is an integer. If we know the
input is an integer it should be safe to pass it directly in to the query.
Am I missing anything?