From fd86c7225336b8b66d1260fb162ef4d1f9360d42 Mon Sep 17 00:00:00 2001 From: kotofos Date: Wed, 11 Aug 2021 11:36:21 +0200 Subject: [PATCH 1/2] Render leading zeros for years 0001-0999 --- pyhive/common.py | 9 ++++++++- pyhive/tests/test_common.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyhive/common.py b/pyhive/common.py index 298633a1..99fe55c8 100644 --- a/pyhive/common.py +++ b/pyhive/common.py @@ -234,7 +234,14 @@ def escape_sequence(self, item): return '(' + ','.join(l) + ')' def escape_datetime(self, item, format, cutoff=0): - dt_str = item.strftime(format) + if format.startswith('%Y'): + # patch for #404 + dt_str = '{:0>4}{}'.format( + item.strftime('%Y'), + item.strftime(format.lstrip('%Y')) + ) + else: + dt_str = item.strftime(format) formatted = dt_str[:-cutoff] if cutoff and format.endswith(".%f") else dt_str return "'{}'".format(formatted) diff --git a/pyhive/tests/test_common.py b/pyhive/tests/test_common.py index 715c7168..8642610f 100644 --- a/pyhive/tests/test_common.py +++ b/pyhive/tests/test_common.py @@ -38,3 +38,7 @@ def test_escape_args(self): ("'2020-04-17'",)) self.assertEqual(escaper.escape_args((datetime.datetime(2020, 4, 17, 12, 0, 0, 123456),)), ("'2020-04-17 12:00:00.123456'",)) + self.assertEqual(escaper.escape_args((datetime.date(2020, 4, 17),)), + ("'2020-04-17'",)) + self.assertEqual(escaper.escape_args((datetime.datetime(20, 4, 17, 12, 0, 0, 123456),)), + ("'0020-04-17 12:00:00.123456'",)) From fc052026380b5c2cb5d99d7461754edc80789ad7 Mon Sep 17 00:00:00 2001 From: kotofos Date: Sat, 6 Nov 2021 20:25:02 +0100 Subject: [PATCH 2/2] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..827afa29 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,32 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: ubuntu-latest +strategy: + matrix: + Python35: + python.version: '3.5' + Python37: + python.version: '3.10' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest'