Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
PostgreSQL tsrange: ¿la superposición ignora los rangos equivalentes?

Tengo una consulta en mi aplicación Rails que se ve así:

 # Returns any records whose period intersect the specified time # @see https://www.postgresql.org/docs/9.3/static/rangetypes.html # @see https://www.postgresql.org/docs/9.3/static/functions-range.html # @note The '()' means exclude both sides of the range # # @param period_start [DateTime,Time] Start of the range # @param period_end [DateTime,Time] End of the range scope :overlapping, ->(period_start, period_end) { where( "#{table_name}.period && tsrange(:period_start, :period_end, '()')", period_start: Time.at(period_start.to_i), # Caps precision to the second period_end: Time.at(period_end.to_i) # Caps precision to the second ).distinct }

Sin embargo, el problema aquí es que no se devuelven los registros que tienen el MISMO período que el rango creado por period_start y period_end . ¿Porqué es eso? Pensé que la superposición verificaba si había alguna intersección.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Sin embargo, el problema aquí es que no se devuelven los registros que tienen el MISMO período que el rango creado por period_start y period_end.

Eso no es cierto. No estoy seguro de cuál es tu problema, pero no es ese.

 SELECT tsrange(x,y), tsrange(x,y) && tsrange(x,y) AS overlaps FROM ( VALUES ('yesterday'::timestamp, 'today'::timestamp) ) AS t(x,y); tsrange | overlaps -----------------------------------------------+---------- ["2017-04-24 00:00:00","2017-04-25 00:00:00") | t (1 row)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!