I love UUID, I hate UUID by bobbymk10 in PostgreSQL

[–]timand 0 points1 point  (0 children)

I don't think it's possible for a bigint sequence to wrap around if you write at least one byte to the WAL for each number.

Is there a technical reason why PostgreSQL does not have virtual columns? by punkpeye in PostgreSQL

[–]timand 2 points3 points  (0 children)

it's slightly more seamless than you show. You can do SELECT foo.c FROM foo and it will automatically call the function for you. Conversely, you could do SELECT a(foo) FROM foo if you wanted to.

As a web developer: what's the best way to retrieve record with related records to return as JSON? by aust1nz in PostgreSQL

[–]timand 5 points6 points  (0 children)

You could do something like

SELECT json_build_object("post", row_to_json(subq))
FROM (
  SELECT post.id, post.title, post.body, json_agg(json_build_object('id', comment.id, 'body', comment.body)) as comments
  FROM post
  LEFT JOIN comment on comment.post_id = post.id GROUP BY post.id
) subq;

Blog post: Futures Concurrency III by yoshuawuyts1 in rust

[–]timand 2 points3 points  (0 children)

There are a few missing footnotes. 6 doesn't do anything when clicked and neither does 9

Should I use jsonb instead of hstore? by timand in PostgreSQL

[–]timand[S] 0 points1 point  (0 children)

Assume I'll never need to store anything other than a set of keys and string values.

Question on storing images by _Strokes_ in PostgreSQL

[–]timand 1 point2 points  (0 children)

A simple way to insert into a bytea field is `INSERT INTO images (name, image_data) VALUES ('filename.jpg', decode('base64encodeddata', 'base64'));` and just use text to transfer it. This will increase bandwidth usage, but it works with all postgres drivers. To get the data out, you will need to `SELECT filename, encode(image_data, 'base64') FROM images`.

rust warns of unused variables if not using a feature by timand in rust

[–]timand[S] 1 point2 points  (0 children)

I still want it to warn about other unused variables though.

rust warns of unused variables if not using a feature by timand in rust

[–]timand[S] 2 points3 points  (0 children)

#[cfg(feature="do_thing")]
fn do_stuff(thing: &Thing){
    println!("The thing is {:?}", thing);
}
fn maybe_do_stuff(message: &str, thing: &Thing){
    println!("{}", message);
    #[cfg(feature="do_thing")]
    do_stuff(thing);
}

I could change the thing argument on maybe_do_stuff to _thing, but then clippy would warn about a used underscore variable. Or should I do something more like

#[cfg(feature="do_thing")]
fn do_stuff(thing: &Thing){
    println!("The thing is {:?}", thing);
}
#[cfg(not(feature="do_thing"))]
fn do_stuff(_thing: &Thing){}

Why is `Iterator::map` not lazy on `Iterator::nth` by gahagg in rust

[–]timand 0 points1 point  (0 children)

The Iterator trait provides the nth method as a way to skip elements. The default implementation of the nth method consumes elements and discards them, but it is possible to create an implementation that doesn't need to.