Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9309977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:00:14+00:00 2026-06-19T01:00:14+00:00

store as Hash Table with Hstore, wrong ordering in Hash after Save class Service

  • 0

store as Hash Table with Hstore, wrong ordering in Hash after Save

class Service < ActiveRecord::Base
  serialize :properties, ActiveRecord::Coders::Hstore
end

service = Service.new
service.properties = { "aaa" => 1, "zz" => 2, "cc" => 3, "d" => 4 }
#=> { "aaa" => 1, "zz" => 2, "cc" => 3, "d" => 4 }
service.save
reload!
service = Service.find(:id)
service.properties
#=> { "d" => "4", "cc" => "3", "zz" => 2, "aaa" => 1 }
Bug::: wrong ordering after save

Is it because after serialize that it orders by Tree. Any ideas or anyone had faced this problem before? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:00:17+00:00Added an answer on June 19, 2026 at 1:00 am

    From the fine PostgreSQL manual:

    F.16. hstore
    […]
    This module implements the hstore data type for storing sets of key/value pairs within a single PostgreSQL value.
    […]
    The order of the pairs is not significant (and may not be reproduced on output).

    So PostgreSQL’s hstore type is an unordered set of key/value pairs that doesn’t guarantee any particular order of the key/value pairs. Once your Ruby Hash is converted to an hstore, the ordering is lost.

    If you need to maintain the order in your Hash you’ll have to use a different serialize format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a hash table class in java where I store the
I'm using a hash table (source code by Google Inc) to store some method
What I can think of is: Algo: Have a hash table which will store
How can I store a hash table with separate chaining in a file on
I never need to store objects in a hash table. The reason is twofold:
I am using a hash table similar to the following to store the letters
I have a hash table that I want to store to disk. The list
I'm trying to use a hash table in C++ to store strings i.e a
I am trying to write a hash table for class and I can't seem
I'm trying to write a C program that uses a hash table to store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.