Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJhdS-004ewP-QO for psycopg@arkaria.postgresql.org; Fri, 06 Dec 2024 23:21:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tJhdP-00EMAv-UL for psycopg@arkaria.postgresql.org; Fri, 06 Dec 2024 23:21:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJhdP-00EMAn-JJ for psycopg@lists.postgresql.org; Fri, 06 Dec 2024 23:21:20 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tJhdJ-001QWx-Eu for psycopg@lists.postgresql.org; Fri, 06 Dec 2024 23:21:19 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5f228d8cd0eso699460eaf.0 for ; Fri, 06 Dec 2024 15:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=progman-us.20230601.gappssmtp.com; s=20230601; t=1733527271; x=1734132071; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=LT6wlu1+9bQlvQ5nRcrNlFGJqOYKuYs9iDIF7gAtcJw=; b=zkAE8n1gmGJbk4XOnlJvA15aSPfhjlchIdHqjbXfXBGTwJ2Dylva/27XNl5ahJDjAd Hglc9Pum6JvXxdk0FLcWlMor8/+CF2xtoagKgcfwLVn81NHDKKg39Icfy8+rW56Dl96Z O4pzD9+Wfv7GU4nm2gdBxdIQiwHm/KpWfAxqZSRH7xYCffClo2zHYGtz6V1XWCOFjLmE 15dxTYuHrfX8dsYd+bGlMsPlrJWEBqbdYcbIU+s1YKYwphHTlhYDu7ZHgFGJ6lvl2+VH k0sZXlLY1u5pL0nsbPPmARxxeQSJXhLVrq89/Dy8viozDQCT6zN6x1EPE5WgqeMgderL YRhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733527271; x=1734132071; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LT6wlu1+9bQlvQ5nRcrNlFGJqOYKuYs9iDIF7gAtcJw=; b=QLRhr2ZhYRjdvI5Kt9jJrLVHi2CWt8I0x7Gfq1oBOoOpHkC3tTTl+1pygKX2OVNxUJ 4xNwd6k+SiZLRpcvT6Xr7CBYXjYS8mjQhYAQynyJMSqFZBLa6XfJyV8K87fNQL/AwhCu iXe9ddO+A71G/iCyNugNnxMKf+IFNGo/0V1o/Q14lVexzCQnuqjaUhsg/3ro3ar73YLR yf7C8EKUMnMdecqrBKUVfbkorAPvLc2+KZ7oI+ugivIQPnrdWa89sa1SdZB9uA2zt2DK +zXE5fQW+wTWWwg38Uqr4seu1WzTtFaMqn24/CPhDj90i+AicZBcTEmArNME9BL0KAO4 thfw== X-Gm-Message-State: AOJu0Yzb/UgR0wG1u50bZs/2jwrOiAkbbWtULEt9oe5HQ0xePEUUVDSE acyEkqIm/3HTorD+a0GhYV0tLkozyfNUpV5ShxZmgBUC2Ne7Nj0e5Y1+mQPcq8kAImjEzay4Y4m l X-Gm-Gg: ASbGncvqBJY1FmIIKbvItG/RDhSs+CbFQuAMBE1P7va/2rFZEi6+guxCfsTExKJIJpU 8p3ac+63vB18Q0bSJPzjf6V/g35uMwNLqDaiBhhyx8H763mGrkFJdcrktzy3YN/oV5PV+4LTQZr UB5PLBWko9dxAdrPcAdvsapqY/NX/3QinaLY4d7W7LhkGk4q0nTjZMMHTt0PhrAM+1lzmji2GbP xL8OEeEicyKaEm2tqXMWM4bPs08f/6z56601sp3gNv2qfMHw99vCBk8LHwHLm2ZpYV/Qu/b4xVa 3QHJx7gApQ34ilrOdRm9ixZG+F1r X-Google-Smtp-Source: AGHT+IHqpnHba+vcEuJS6NSs70wQT2xBpr44Rt1vrpKqKMldFB/jhb32PG/5stZMJDxMRhaLaAO6dg== X-Received: by 2002:a05:6820:1a08:b0:5e8:35c:3401 with SMTP id 006d021491bc7-5f28710b2e7mr2879956eaf.6.1733527271088; Fri, 06 Dec 2024 15:21:11 -0800 (PST) Received: from [192.168.240.43] (69-110-49-32.lightspeed.okcbok.sbcglobal.net. [69.110.49.32]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f27932381asm936788eaf.44.2024.12.06.15.21.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2024 15:21:10 -0800 (PST) Message-ID: <3143b3b4-c22c-4fed-ab6c-aa371a3cd288@progman.us> Date: Fri, 6 Dec 2024 17:21:10 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Parameter in SQL query being misinterpreted To: psycopg@lists.postgresql.org References: Content-Language: en-US From: Daniel Johnson In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/5/24 20:39, Daniele Varrazzo wrote: > Adrian has already provided a few workarounds for the problem you > report - thank you very much!. The one I prefer is however the > following, because it does without string operations: it makes use of > the possibility to multiply an interval by a scalar: > > >>> cur.execute("select now(), now() + %s * '1 second'::interval", > (10,)).fetchone() > (datetime.datetime(2024, 12, 6, 2, 33, 32, 117134, > tzinfo=zoneinfo.ZoneInfo(key='Europe/London')), > datetime.datetime(2024, 12, 6, 2, 33, 42, 117134, > tzinfo=zoneinfo.ZoneInfo(key='Europe/London'))) Oh I hadn't even thought about multiplying an interval, that's a very clean approach. Prior to e-mailing the list I'd tried something similar to (but not as thorough as) Adrian's suggestion and it had failed, but if it works I like the look of this. I vaguely recall having a similar interval manipulation headache in a PHP portion of this project, I shall try the same thing there. Thank you so much! Daniel Johnson djohnson@progman.us