Skip to content

Commit

Permalink
(PDB-4269) PQL: support 64-bit integers (matching puppet)
Browse files Browse the repository at this point in the history
Match the current "practical limit" on integers.  Previously PQL
integers were 32-bit:

  https://puppet.com/docs/puppet/6.17/lang_data_number.html#lang_data_number_integer_type
  • Loading branch information
rbrw authored and austb committed Aug 5, 2020
1 parent e3abb42 commit 189bb7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/puppetlabs/puppetdb/pql/transform.clj
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@
:false false))

(defn transform-integer
;; 64-bit
;; https://puppet.com/docs/puppet/5.3/lang_data_number.html#the-integer-data-type
([int]
(Integer. int))
(Long. int))
([neg int]
(- (Integer. int))))
(Long. (str neg int))))

(defn transform-real
[& args]
Expand Down
3 changes: 3 additions & 0 deletions test/puppetlabs/puppetdb/pql_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
["from" "nodes"
["and" ["=" "a" 1] ["=" "b" 2]]]

(format "nodes { a = %d and b = %d }" Long/MAX_VALUE Long/MIN_VALUE)
["from" "nodes"
["and" ["=" "a" Long/MAX_VALUE] ["=" "b" Long/MIN_VALUE]]]

"fact_contents {path = [\"foo\",\"bar\"]}"
["from" "fact_contents"
Expand Down

0 comments on commit 189bb7b

Please sign in to comment.