Coder Social home page Coder Social logo

Comments (4)

jamesgpearce avatar jamesgpearce commented on May 22, 2024 1

Sorry I was off the grid for a few days. I’ll take a look at this and propose a few solutions. Thanks for your patience and being a TinyBase supporter! :)

from tinybase.

jamesgpearce avatar jamesgpearce commented on May 22, 2024

@kastriotkastrati take a look at the test cases in

describe('Coerce Ids', () => {
let store: Store;
beforeEach(() => {
store = createStore();
});
describe('Table Id', () => {
test('setTables, setCell', () => {
store.setTables({1: {r1: {c1: 1}}});
expect(store.getTables()).toEqual({1: {r1: {c1: 1}}});
// @ts-ignore
store.setCell(1, 'r1', 'c2', 2);
expect(store.getTable('1')).toEqual({r1: {c1: 1, c2: 2}});
});
test('setTable, setCell', () => {
// @ts-ignore
store.setTable(1, {r1: {c1: 1}});
expect(store.getTable('1')).toEqual({r1: {c1: 1}});
// @ts-ignore
store.setCell(1, 'r1', 'c2', 2);
expect(store.getTable('1')).toEqual({r1: {c1: 1, c2: 2}});
});
test('setRow, setCell', () => {
// @ts-ignore
store.setRow(1, 'r1', {c1: 1});
expect(store.getRow('1', 'r1')).toEqual({c1: 1});
// @ts-ignore
store.setCell(1, 'r1', 'c2', 2);
expect(store.getTable('1')).toEqual({r1: {c1: 1, c2: 2}});
});
test('setCell, setCell', () => {
// @ts-ignore
store.setCell(1, 'r1', 'c1', 1);
expect(store.getCell('1', 'r1', 'c1')).toEqual(1);
// @ts-ignore
store.setCell(1, 'r1', 'c2', 2);
expect(store.getTable('1')).toEqual({r1: {c1: 1, c2: 2}});
});
});
describe('Row Id', () => {
test('setTables, setCell', () => {
store.setTables({t1: {1: {c1: 1}}});
expect(store.getTables()).toEqual({t1: {1: {c1: 1}}});
// @ts-ignore
store.setCell('t1', 1, 'c2', 2);
expect(store.getRow('t1', '1')).toEqual({c1: 1, c2: 2});
});
test('setTable, setCell', () => {
store.setTable('t1', {1: {c1: 1}});
expect(store.getTable('t1')).toEqual({1: {c1: 1}});
// @ts-ignore
store.setCell('t1', 1, 'c2', 2);
expect(store.getRow('t1', '1')).toEqual({c1: 1, c2: 2});
});
test('setRow, setCell', () => {
// @ts-ignore
store.setRow('t1', 1, {c1: 1});
expect(store.getRow('t1', '1')).toEqual({c1: 1});
// @ts-ignore
store.setCell('t1', 1, 'c2', 2);
expect(store.getRow('t1', '1')).toEqual({c1: 1, c2: 2});
});
test('setCell, setCell', () => {
// @ts-ignore
store.setCell('t1', 1, 'c1', 1);
expect(store.getCell('t1', '1', 'c1')).toEqual(1);
// @ts-ignore
store.setCell('t1', 1, 'c2', 2);
expect(store.getRow('t1', '1')).toEqual({c1: 1, c2: 2});
});
});
describe('Cell Id', () => {
test('setTables, setCell', () => {
store.setTables({t1: {r1: {1: 1}}});
expect(store.getTables()).toEqual({t1: {r1: {1: 1}}});
// @ts-ignore
store.setCell('t1', 'r1', 2, 2);
expect(store.getCell('t1', 'r1', '1')).toEqual(1);
expect(store.getCell('t1', 'r1', '2')).toEqual(2);
});
test('setTable, setCell', () => {
store.setTable('t1', {r1: {1: 1}});
expect(store.getTable('t1')).toEqual({r1: {1: 1}});
// @ts-ignore
store.setCell('t1', 'r1', 2, 2);
expect(store.getCell('t1', 'r1', '1')).toEqual(1);
expect(store.getCell('t1', 'r1', '2')).toEqual(2);
});
test('setRow, setCell', () => {
store.setRow('t1', 'r1', {1: 1});
expect(store.getRow('t1', 'r1')).toEqual({1: 1});
// @ts-ignore
store.setCell('t1', 'r1', 2, 2);
expect(store.getCell('t1', 'r1', '1')).toEqual(1);
expect(store.getCell('t1', 'r1', '2')).toEqual(2);
});
test('setCell, setCell', () => {
// @ts-ignore
store.setCell('t1', 'r1', 1, 1);
// @ts-ignore
store.setCell('t1', 'r1', 2, 2);
expect(store.getCell('t1', 'r1', '1')).toEqual(1);
expect(store.getCell('t1', 'r1', '2')).toEqual(2);
});
});
});
- these failed without the other changes in the diff. Basically everything gets coerced to a string at the API level, so no numeric keys should ever exist or be queried in the underlying storage structure.

from tinybase.

jamesgpearce avatar jamesgpearce commented on May 22, 2024

Please update to package v1.3.6 and confirm the issue is resolved! Thanks.

from tinybase.

kastriotkastrati avatar kastriotkastrati commented on May 22, 2024

@jamesgpearce Yep, the issue is solved. Thank you:)
https://stackblitz.com/edit/react-ts-bkf8jn?file=App.tsx

from tinybase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.