#
# PUT a VCARD record into an addressbook
#
TYPE=PUT
URL=http://regression.host/caldav.php/user1/addressbook/donald_kelly.vcf

HEADER=Content-Type: text/vcard; charset=utf-8
HEAD

DOSQL
DELETE FROM caldav_data WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
ENDDOSQL

BEGINDATA
begin:vcard
fn:Donald Kelly
n:Kelly;Donald;;;
org:Esposo Designs Ltd
adr:;;25 Rintoul St;Newtown;Wellington;;New Zealand
email;type=internet:donald@example.co.nz
title:Proprietor
tel;type=work:+64 4 347 4747
tel;type=cell:+64 2 1234-4321
x-mozilla-html:TRUE
url:www.example.co.nz
version:2.1
end:vcard
ENDDATA

QUERY
SELECT caldav_data.caldav_data, caldav_data.dav_id FROM caldav_data WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
ENDQUERY

QUERY
SELECT caldav_data.dav_name, caldav_data.dav_etag IS NOT NULL AS "etag_not_null",
       version, uid IS NOT NULL AS "uid_not_null", nickname, fn, n, note, org, url, fburl, caladruri, caluri
  FROM caldav_data LEFT JOIN addressbook_resource USING(dav_id)
  WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
ENDQUERY

QUERY
SELECT 
       type, box_no, unit_no, street_address, locality, region, postcode, country, property
  FROM caldav_data 
        LEFT JOIN addressbook_address_adr USING(dav_id)
  WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
  ORDER BY dav_id, property
ENDQUERY

QUERY
SELECT 
        addressbook_address_tel.type, addressbook_address_tel.tel
  FROM caldav_data
        LEFT JOIN addressbook_address_tel USING(dav_id)
  WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
  ORDER BY dav_id, property
ENDQUERY

QUERY
SELECT 
        addressbook_address_email.type, addressbook_address_email.email
  FROM caldav_data
        LEFT JOIN addressbook_address_email USING(dav_id)
  WHERE caldav_data.dav_name ~ '/user1/addressbook/donald_kelly.vcf'
  ORDER BY dav_id, property
ENDQUERY


