Tagged Questions
1
vote
0answers
19 views
Ruby on rails form for postgresql array
I haven't found any example of how to make a dynamic form for a field which is a Postgresql array.
I want to fill it dynamically using Mustache.js. I have done it before but with a string field using ...
0
votes
1answer
25 views
Using WHERE clause to only retrieve results where array field has only ONE element inside
I have a table with various arrays within it like this:
{10574664,10574665,10574679,10574724}
{8616204,10574643,10574644,10574645,10574651,10574688,10574690,10574696,10574708}
{8616208}
{9830397}
...
2
votes
1answer
20 views
How to use xpath in Postgres to align XML elements
This query:
with x as (select
'<promotions>
<promotion promotion-id="old-promotion">
<enabled-flag>true</enabled-flag>
...
1
vote
1answer
24 views
Array field not being recognized as attribute
I have the following model I created,
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string ...
0
votes
1answer
22 views
PostgreSQL HSTORE GIN query
I can't figure out how to re-write this query using arrays for the test cases:
--explain
SELECT COUNT(id)
FROM (
SELECT T.id
FROM product2 AS T
WHERE (ext @> 'p01=>1' OR ...
0
votes
1answer
37 views
How to aggregate all array values of multiple records in Postgres array?
I have a table full of records and an array column, and now I want to get a list of all (unique) values in that column. What's the best way of getting that?
I tried playing around with unnest, ...
2
votes
2answers
41 views
Return array of years as year ranges
I'm attempting to query a table which contains a character varying[] column of years, and return those years as a string of comma-delimited year ranges. The year ranges would be determined by ...
0
votes
2answers
71 views
Python: Array vs Database for storage of key/value
Q: Which is quicker for this scenario?
My scenario: my application will be storing either in either an array or postgresql db a list of links, so it might look like:
1) mysite.com
a) ...
0
votes
2answers
31 views
Outputting a query of rows to a table in php
I'm using the below code to output rows from my table called data_cases:
$query = 'SELECT * FROM mydb.data_cases
WHERE id=123 ORDER BY log_date_time DESC';
$result = pg_query($query) or ...
2
votes
3answers
273 views
New data not persisting to Rails array column on Postgres
I have a user model with a friends column of type text. This migration was ran to use the array feature with postgres:
add_column :users, :friends, :text, array: true
The user model has this ...
0
votes
1answer
45 views
PostgreSQL PDO insert into array type
I'm trying to use PHP PDO to insert values into a PostgreSQL database, but encounter the following error message:
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: array value must start with ...
4
votes
1answer
126 views
Large array in database won't load in rails view
I am trying to pull in data from an array into a view to form a chart. The array is stored in a database field and is very large. The array contains around 70k+ smaller arrays that look like this, ...
6
votes
2answers
148 views
Why is PostgreSQL array access so much faster in C than in PL/pgSQL?
I have a table schema which includes an int array column, and a custom aggregate function which sums the array contents. In other words, given the following:
CREATE TABLE foo (stuff INT[]);
INSERT ...
1
vote
1answer
67 views
Postgres data type integer[] in ruby
ruby : ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
@user = User.find(1)
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
=> ...
4
votes
1answer
27 views
How to get array from non-array field for INSERT command?
I'm trying to use a SELECT statement together with a INSERT INTO command. Everything would work fine, if there wasn't a small problem: some fields of the table are defined as real[] but my input is ...